November 20, 2008, 05:42:47 pm *
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Quering types declared in body of a method or a constructor (callable)  (Read 1051 times)
rterrabh
Newbie
*
Posts: 1


« on: June 24, 2008, 03:10:15 am »

Good evening.

My master degree is about architecture conformance and I proposed a "dependency constraint language" and I'm using .QL for all these proposed constraints.

However, I'm having difficulties with a constraint which declares that one module A can-declare variables of a type.

By example: only A can-declare B.

Query returns all classes which declare a attribute of type B:
    from Field f, Class clazz
    where
        clazz.hasQualifiedName("com.terra","B") and
        f.getType() = clazz
    select f.getDeclaringType().getQualifiedName()


Query returns all classes and their methods or constructors which declare a parameter of type B:
    from Callable c, Class clazz
    where
        clazz.hasQualifiedName("com.terra","B") and
        c.getAParameter().getType() = clazz
    select c.getDeclaringType().getQualifiedName(), c.getStringSignature()


Then, my difficult is: How I use .QL to return all methods or constructors which declare the type B in their bodies?

Thanks a lot,

Ricardo Terra
Logged
Oege de Moor
Newbie
*
Posts: 30


« Reply #1 on: June 24, 2008, 12:47:16 pm »

Thanks for your interest.

We are putting the finishing touches on a new version of SemmleCode that stores the whole program (everything, comments, javadoc, statements, expressions, ...). With that new version, you can query for local variables declared in a method body, and thus do what you are suggesting. For example, on my local development version, I just wrote the query:

Code:
from LocalVariableDecl d
where d.getType().hasName("TestBean")
select d.getCallable()

which finds all callables that declare a variable of a type named "TestBean".

Thanks for your interest and patience,

-Oege

Logged
Pages: [1]
  Print  
 
Jump to: