PsiElement (PsiElement element) { final RncDefine define = PsiTreeUtil.getParentOfType(element, RncDefine.class, false); RncGrammar target = define != null ? PsiTreeUtil.getParentOfType(define, RncGrammar.class, false) : null; return target != null && target.getText().startsWith("grammar ") ? target : null; }