PsiElement (@NotNull PsiReference ref, int flags) { PsiElement sourceElement = ref.getElement(); if (sourceElement instanceof GrCodeReferenceElement) { GrNewExpression newExpr; PsiElement parent = sourceElement.getParent(); if (parent instanceof GrNewExpression) { newExpr = (GrNewExpression)parent; } else if (parent instanceof GrAnonymousClassDefinition) { PsiElement grandParent = parent.getParent(); if (grandParent instanceof GrNewExpression) { newExpr = (GrNewExpression)grandParent; } else { return null; } } else { return null; } final PsiMethod constructor = newExpr.resolveMethod(); if (constructor instanceof DefaultConstructor) return constructor.getContainingClass(); final GrArgumentList argumentList = newExpr.getArgumentList(); if (constructor != null && argumentList != null && PsiImplUtil.hasNamedArguments(argumentList) && !PsiImplUtil.hasExpressionArguments(argumentList)) { if (constructor.getParameterList().isEmpty()) return constructor.getContainingClass(); } return constructor; } if (sourceElement instanceof GrReferenceExpression) { PsiElement resolved = ((GrReferenceExpression)sourceElement).resolve(); if (resolved instanceof GrGdkMethod || !(resolved instanceof GrRenameableLightElement)) { return correctSearchTargets(resolved); } return resolved; } return null; }