PsiExpression (PsiExpression methodReferenceExpression) { final PsiElement parent = methodReferenceExpression.getParent(); if (parent instanceof PsiTypeCastExpression) { final PsiTypeElement typeElement = ((PsiTypeCastExpression)parent).getCastType(); if (typeElement != null) { final PsiClass resolvedClass = PsiTypesUtil.getPsiClass(typeElement.getType()); if (resolvedClass != null && myTargetClassQName.equals(resolvedClass.getQualifiedName())) { methodReferenceExpression = (PsiExpression)parent.replace(methodReferenceExpression); } } } setStringToReplace("$qualifier$::" + myMethodName); setReplaceByString("$qualifier$"); return methodReferenceExpression; }