I’m trying to write a detekt extension using PSI, ...
# compiler
c
I’m trying to write a detekt extension using PSI, but I’m having a hard time finding a good starting point for learning about how to navigate the hierarchies. This explains what I’m trying to do. I think my starting point would be to obtain a
KtDotQualifiedExpression
, but I’m not sure where to go from there. My hierarchy looks something like this:
Copy code
DOT_QUALIFIED_EXPRESSION(891,920)
            REFERENCE_EXPRESSION(891,897)
              PsiElement(IDENTIFIER)('sender')(891,897)
            PsiElement(DOT)('.')(897,898)
            CALL_EXPRESSION(898,920)
              REFERENCE_EXPRESSION(898,907)
                PsiElement(IDENTIFIER)('sendEvent')(898,907)
              VALUE_ARGUMENT_LIST(907,920)
                PsiElement(LPAR)('(')(907,908)
                VALUE_ARGUMENT(908,919)
                  CALL_EXPRESSION(908,919)
                    REFERENCE_EXPRESSION(908,917)
                      PsiElement(IDENTIFIER)('SomeEvent')(908,917)
                    VALUE_ARGUMENT_LIST(917,919)
                      PsiElement(LPAR)('(')(917,918)
                      PsiElement(RPAR)(')')(918,919)
                PsiElement(RPAR)(')')(919,920)
I essentially want to determine if the
EventSender#sendEvent
method is being called, and if the parameter being passed is annotated properly. So far I haven’t been able to figure out how to obtain the type of
sender
to determine if it’s the
sendEvent
I even care about. Any help is appreciated.