ElementPattern<PsiElement> () { final ElementPattern<PsiElement> patternForParent = or(psiElement().withText(CompletionInitializationContext.DUMMY_IDENTIFIER_TRIMMED) .afterSiblingSkipping(psiElement(PsiWhiteSpace.class), psiElement(PsiJavaToken.class).withText("="))); return psiElement().withParent(patternForParent).withSuperParent(2, or(psiElement(PsiAssignmentExpression.class), psiElement(PsiLocalVariable.class) .inside(PsiDeclarationStatement.class))).inside(PsiMethod.class); }