Reputation: 1336
How can we find undeclared variables in eclipse's JDT MethodDeclaration body?
Upvotes: 0
Views: 83
Reputation: 8178
I assume you are looking for references that cannot be resolved (because the intended variable has not been declared), right?
You should create your AST with setResolveBindings(true)
and then search for Name
s whose resolveBinding()
is null
. This will also find unresolved type references, where a SimpleType
or QualifiedType
contains a Name
node. This can be detected by asking name.getParent() instanceof Type
. If true
then it's not a variable reference.
Upvotes: 1