I want to build an Intellij plugin that identifies scala classes with certain annotations.
ex:
@RunWith(classOf[SimpleTestRunner])
When I build the PSITree using the PSIViewer pluging for the last code segment I get this Tree
ScalaFile:Dummy.scala(0,36)
PsiErrorElement:Wrong top statement declaration(0,0)
<empty list>
PsiElement(@)('@')(0,1)
MethodCall(1,35)
ReferenceExpression: RunWith(1,8)
PsiElement(identifier)('RunWith')(1,8)
ArgumentList(8,35)
PsiElement(()('(')(8,9)
GenericCall(9,34)
ReferenceExpression: classOf(9,16)
PsiElement(identifier)('classOf')(9,16)
TypeArgumentsList(16,34)
PsiElement([)('[')(16,17)
SimpleType: SimpleTestRunner(17,33)
CodeReferenceElement: SimpleTestRunner(17,33)
PsiElement(identifier)('SimpleTestRunner')(17,33)
PsiElement(])(']')(33,34)
PsiElement())(')')(34,35)
Now, I'm trying to access children with navigation element "ReferenceExpression,ArgumentList,GenericCall", I know how to visit tree recursively, but I don't know what to look for.
So can someone tell me what are the interfaces that represents these elements or is there sort of a utiltiy class that could help me to do so?
I assume you have the source code of the Scala plugin?
The interfaces (or Scala traits actually) are defined in the org.jetbrains.plugins.scale.lang.psi.api package. There you can find ./expr/ScGenericCall.scala for example. Every element in your tree has a corresponding Sc<NAME>.scala file where it is defined.