use of org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrRenameableLightElement in project intellij-community by JetBrains.
the class GroovyTargetElementEvaluator method getElementByReference.
@Override
public PsiElement getElementByReference(@NotNull PsiReference ref, int flags) {
PsiElement sourceElement = ref.getElement();
if (sourceElement instanceof GrCodeReferenceElement) {
GrNewExpression newExpr;
if (sourceElement.getParent() instanceof GrNewExpression) {
newExpr = (GrNewExpression) sourceElement.getParent();
} else if (sourceElement.getParent().getParent() instanceof GrNewExpression) {
//anonymous class declaration
newExpr = (GrNewExpression) sourceElement.getParent().getParent();
} else {
return null;
}
final PsiMethod constructor = newExpr.resolveMethod();
final GrArgumentList argumentList = newExpr.getArgumentList();
if (constructor != null && argumentList != null && PsiImplUtil.hasNamedArguments(argumentList) && !PsiImplUtil.hasExpressionArguments(argumentList)) {
if (constructor.getParameterList().getParametersCount() == 0)
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;
}
Aggregations