Hi, I want to get the modifiers of a variable, when it is used, can I do that?
Resource@modifiers <Entity methodOrField, Modifier>:
<entity([
package("subfolder"),
class("Const"),
field("JASPER")
]),static()>,
<entity([
package("subfolder"),
class("Const"),
field("JASPER")
]),final()>
Resource@methodBodies: <Entity method, AstNode body>:
qualifiedName("Const.JASPER")[@javaType=entity([primitive(int())]
Resource@fields: <loc fileAndPosition, Entity field>
<|project://SampleJava/src/subfolder/TestX.java|(365,6,<-1,-1>,<-1,-1>),entity([
package("subfolder"),
class("Const"),
field("JASPER")
])
>
Resource@fieldDecls: <loc fileAndPosition, Entity field>
<|project://SampleJava/src/subfolder/Const.java|(45,36,<-1,-1>,<-1,-1>),entity([
package("subfolder"),
class("Const"),
field("JASPER")
])>
Big question is, if I encounter a qualifiedName of type int in an AstNode, how can I easily extract the modifiers for it? Somewhere should also be a field constructor containing the modifiers, but that is not in the methodBodies, because it's on class level.
Its possible, and rather complicated. You should tie some of the relations of JDT together and use locations. Were adding better API for this now. Thanks!
Asked: Dec 19 '11
Seen: 13 times
Last updated: Dec 29 '11
Copyright CWI, 2010-2012. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.