Hi Kirill,
the answer to your second question is YES, you can easily add methods to the existing classes. The existing classes are all defined in the default.ql file that comes with the plugin. To open it, you need to select "Open library" menu item in one of the plugin view's pull down menu.
Now to answer your first question, here is an example of a custom class with the function that you wanted to define:
class MyClass extends Class {
int getNumberOfLinesOfCode() {
result = this.getLocation().getNumberOfLines()
}
}
from MyClass c
where c.getNumberOfLinesOfCode() > 120
select c.getName(), c.getNumberOfLinesOfCode()
If you would rather like to have the function getNumberOfLinesOfCode() in the Class class itself, feel free to move its definition to the Class class in the default.ql file. More information on this topic can be found in the tutorial.
Semmle Coders