use of org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement in project intellij-community by JetBrains.
the class GrNewExpressionImpl method getCallVariants.
@Override
@NotNull
public GroovyResolveResult[] getCallVariants(@Nullable GrExpression upToArgument) {
final GrCodeReferenceElement referenceElement = getReferenceElement();
if (referenceElement == null)
return GroovyResolveResult.EMPTY_ARRAY;
List<GroovyResolveResult> result = new ArrayList<>();
for (GroovyResolveResult classResult : referenceElement.multiResolve(false)) {
final PsiElement element = classResult.getElement();
if (element instanceof PsiClass) {
ContainerUtil.addAll(result, ResolveUtil.getAllClassConstructors((PsiClass) element, classResult.getSubstitutor(), null, this));
}
}
return result.toArray(new GroovyResolveResult[result.size()]);
}
use of org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement in project intellij-community by JetBrains.
the class GrTypeParameterParameterExtendsListImpl method getReferencedTypes.
@Override
@NotNull
public PsiClassType[] getReferencedTypes() {
final GrCodeReferenceElement[] refs = findChildrenByClass(GrCodeReferenceElement.class);
PsiClassType[] result = new PsiClassType[refs.length];
for (int i = 0; i < result.length; i++) {
result[i] = new GrClassReferenceType(refs[i]);
}
return result;
}
use of org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement in project intellij-community by JetBrains.
the class GrImportStatementImpl method getImportedName.
@Override
@Nullable
public String getImportedName() {
if (isOnDemand())
return null;
GrImportStatementStub stub = getStub();
if (stub != null) {
String name = stub.getAliasName();
if (name != null) {
return name;
}
String referenceText = stub.getReferenceText();
if (referenceText == null)
return null;
return StringUtil.getShortName(referenceText);
}
PsiElement aliasNameElement = getAliasNameElement();
if (aliasNameElement != null) {
return aliasNameElement.getText();
}
GrCodeReferenceElement ref = getImportReference();
return ref == null ? null : ref.getReferenceName();
}
use of org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement in project intellij-community by JetBrains.
the class GrPackageDefinitionImpl method getPackageName.
@Override
public String getPackageName() {
final GrPackageDefinitionStub stub = getStub();
if (stub != null) {
return stub.getPackageName();
}
GrCodeReferenceElement ref = getPackageReference();
if (ref == null)
return "";
return PsiUtil.getQualifiedReferenceText(ref);
}
use of org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement 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