private PsiClass getPsiClassFromContext ( AnActionEvent e ) { PsiFile psiFile = e . getData ( LangDataKeys . PSI_FILE ) ; Editor editor = e . getData ( PlatformDataKeys . EDITOR ) ; if ( psiFile == null || editor == null ) { return null ; } int offset = editor . getCaretModel ( ) . getOffset ( ) ; PsiElement element = psiFile . findElementAt ( offset ) ; return PsiTreeUtil . getParentOfType ( element , PsiClass . class ) ; }
Get the class where currently the curser is