boolean (final PsiElement pattern, PsiElement candidate) { if (pattern instanceof PsiReturnStatement && candidate instanceof PsiExpressionStatement) return true; if (pattern instanceof PsiReturnStatement && candidate instanceof PsiDeclarationStatement) return true; if (pattern instanceof PsiThisExpression && candidate instanceof PsiReferenceExpression) return true; final ASTNode node1 = pattern.getNode(); final ASTNode node2 = candidate.getNode(); if (node1 == null || node2 == null) return false; if (node1.getElementType() != node2.getElementType()) return false; if (pattern instanceof PsiUnaryExpression) { return ((PsiUnaryExpression)pattern).getOperationTokenType() == ((PsiUnaryExpression)candidate).getOperationTokenType(); } if (pattern instanceof PsiPolyadicExpression) { return ((PsiPolyadicExpression)pattern).getOperationTokenType() == ((PsiPolyadicExpression)candidate).getOperationTokenType(); } return true; }