November 20, 2008, 07:55:58 am *
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: .QL: Complete language reference  (Read 1941 times)
tadhgp
Newbie
*
Posts: 6


« on: July 09, 2007, 09:32:05 am »

I'm trying to write a semmle query to search for variables which are bound to classes which implement EntityBean and which are initially located through an InitialContext.lookup()

Having gone through all the tutorials, I think it should be possible to do this in .QL, and I have a very precise idea of what I'm trying to find, because I've already written it in a declarative language. However, I'm finding it hard to do in semmle for a couple of reasons.

First, there seems to be a bug when writing a semmle class, I'm not able to bring down the Context Assist (CTRL+SPACE) in Eclipse on the this. element while writing classes.

This in itself wouldn't be a problem if it weren't for the second issue, I can't find a complete reference of exactly what methods are available to me at any given point. It seems the only way to get this is the Context Assist, I can't find it on this website at all. For example, can I do this.getACallable() ? Probably not but I have no way of knowing. Is there something like a Java-API style reference for QL already online that I just can't find?

Any help appriciated!
Logged
elnar
Administrator
Newbie
*****
Posts: 17


« Reply #1 on: July 09, 2007, 01:27:04 pm »

Hi,

usually Context Assist should work on "this" when defining new classes. Could you provide an example of a class on which when typing "this." Context Assist fails, so we could fix it for the next release?

You can find the description of all the methods with their extensive comments here: http://semmle.com/documentation/semmlecode/default-definitions/.

If "this" is a subtype of type EntityBean then this.getACallable() is a valid call since EntityBean inherits the getACallable() method from its supertype RefType.

Hope it helps. Would be interesting to see your query. Cheers.
Logged
tadhgp
Newbie
*
Posts: 6


« Reply #2 on: July 09, 2007, 09:42:46 pm »

I found the reason why I'm not getting the context menu earlier: it seems classes have to extend other classes (correct?), if I just write
Code:
class BetweenCode{
    BetweenCode(){
         this.CTRL_SPACE
    }
}
nothing happens. But if I extend some other class, then obviously, I get the context help associated with that class.

Another question I have is, is there any built-in predicate that i can use to examine the block of code between two points to check to see whether it contains a method call? I don't want to check a whole method or class, simply between two specified calls that may occur in the same class.


Logged
elnar
Administrator
Newbie
*****
Posts: 17


« Reply #3 on: July 10, 2007, 09:54:15 am »

The reason why you are not getting the Context Assist menu in your example is because your newly defined class has no methods in it. If you define at least one method, say toString(), then Context Assist will show it for you. So it is not a bug.

If you declare a class to extend another class then your newly defined class inherits method definitions from its parent and so the Context Assist can show you those methods.

Currently, we do not store the control flow information and so it is not possible to easily check if a method call is between other statements. However, you could try to achieve some approximation by using the locations predicate. Using the locations predicate you can check if one call precedes another. For more information on what data is stored in the locations table check this link: http://semmle.com/documentation/semmlecode/database-contents/.
 
Logged
tadhgp
Newbie
*
Posts: 6


« Reply #4 on: July 10, 2007, 06:29:39 pm »

When you say "one call precedes another" - does precedes mean in terms of line-in-source-code location or in terms of control flow location? I'm guessing the former :/
Logged
elnar
Administrator
Newbie
*****
Posts: 17


« Reply #5 on: July 11, 2007, 08:21:21 am »

Yes, that's right. I mean the former. That is why I said that it will still be not 100% precise. Given enough interest, we might add control flow information to the database at some stage.
Logged
Pages: [1]
  Print  
 
Jump to: