Hi all!
How can I extract the type of a given VariableReference? For example, we have the following call to a method (i.e. a MethodReference):
obj.foo();
Then how do I make Recoder to report the type of 'obj'?
Note, I can get hold of the 'obj' by calling getReferencePrefix() on my MethodReference object -- that call returns a VariableReference-object.
Thanks for any answers and hints!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
you should have the given ServiceConfiguration at hand. From it, you get the SourceInfo (getSourceInfo()). On it, you call getType(varRef). Therefore:
serviceConfiguration.getSourceInfo().getType(varRef).
You can be sure to get an instanceof of "ClassType". The code would be invalid otherwise (the only alternative to ClassType is PrimitiveType, on which no method can be called, obviously).
Hope that helps.
Tobias
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all!
How can I extract the type of a given VariableReference? For example, we have the following call to a method (i.e. a MethodReference):
obj.foo();
Then how do I make Recoder to report the type of 'obj'?
Note, I can get hold of the 'obj' by calling getReferencePrefix() on my MethodReference object -- that call returns a VariableReference-object.
Thanks for any answers and hints!
Hej,
you should have the given ServiceConfiguration at hand. From it, you get the SourceInfo (getSourceInfo()). On it, you call getType(varRef). Therefore:
serviceConfiguration.getSourceInfo().getType(varRef).
You can be sure to get an instanceof of "ClassType". The code would be invalid otherwise (the only alternative to ClassType is PrimitiveType, on which no method can be called, obviously).
Hope that helps.
Tobias