PsiNamedElement (final PsiElement el) { if (patternElements.length == 1 && patternElements[0] instanceof PsiExpressionStatement) { final PsiExpression expression = ((PsiExpressionStatement)patternElements[0]).getExpression(); if (expression instanceof PsiReferenceExpression && ((PsiReferenceExpression)expression).getQualifierExpression() == null) { // looks like symbol replacements, namely replace AAA by BBB, so lets do the best if (el instanceof PsiNamedElement) { return (PsiNamedElement)el; } } } return null; }