Result (Expression @NotNull [] params, final ExpressionContext context) { PsiElement elementAtStartOffset = context.getPsiElementAtStartOffset(); PsiElement place = elementAtStartOffset; while(place != null){ if (place instanceof PsiMethod){ return new TextResult(((PsiMethod)place).getName()); } else if (place instanceof PsiClassInitializer) { return ((PsiClassInitializer) place).hasModifierProperty(PsiModifier.STATIC) ? new TextResult(JavaBundle.message("java.terms.static.initializer")) : new TextResult(JavaBundle.message("java.terms.instance.initializer")); } place = place.getParent(); } if (elementAtStartOffset != null) { PsiElement sibling = elementAtStartOffset.getNextSibling(); if (sibling instanceof PsiMethod) { return new TextResult(((PsiMethod)sibling).getName()); } } return null; }