PsiElementPredicate () { return new PsiElementPredicate() { @Override public boolean satisfiedBy(@NotNull PsiElement element) { PsiElement parent = element.getParent(); if (element instanceof GrTypeElement || element instanceof GrModifierList) { return parent instanceof GrVariableDeclaration && ((GrVariableDeclaration)parent).getTypeElementGroovy() != null || parent instanceof GrMethod && ((GrMethod)parent).getReturnTypeElementGroovy() != null; } if (parent instanceof GrNamedElement && ((GrNamedElement)parent).getNameIdentifierGroovy().equals(element)) { if (parent instanceof GrVariable) { return ((GrVariable)parent).getTypeElementGroovy() != null; } if (parent instanceof GrMethod && ((GrMethod)parent).findSuperMethods().length == 0 ) { return ((GrMethod)parent).getReturnTypeElementGroovy() != null; } } return false; } }; }