use of org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult in project intellij-community by JetBrains.
the class ResolveUtil method collectExpectedParamsByArg.
@NotNull
public static List<Pair<PsiParameter, PsiType>> collectExpectedParamsByArg(@NotNull PsiElement place, @NotNull GroovyResolveResult[] variants, @NotNull GrNamedArgument[] namedArguments, @NotNull GrExpression[] expressionArguments, @NotNull GrClosableBlock[] closureArguments, @NotNull GrExpression arg) {
List<Pair<PsiParameter, PsiType>> expectedParams = ContainerUtil.newArrayList();
for (GroovyResolveResult variant : variants) {
final Map<GrExpression, Pair<PsiParameter, PsiType>> map = GrClosureSignatureUtil.mapArgumentsToParameters(variant, place, true, true, namedArguments, expressionArguments, closureArguments);
if (map != null) {
final Pair<PsiParameter, PsiType> pair = map.get(arg);
ContainerUtil.addIfNotNull(expectedParams, pair);
}
}
return expectedParams;
}
use of org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult in project intellij-community by JetBrains.
the class GroovyResolverProcessor method getCandidatesArray.
public final GroovyResolveResult[] getCandidatesArray() {
final List<GroovyResolveResult> candidates = getCandidates();
final int size = candidates.size();
if (size == 0)
return GroovyResolveResult.EMPTY_ARRAY;
if (size == 1)
return new GroovyResolveResult[] { candidates.get(0) };
return candidates.toArray(new GroovyResolveResult[size]);
}
use of org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult in project intellij-community by JetBrains.
the class GroovyResolverProcessorImpl method filterCorrectParameterCount.
private List<GroovyResolveResult> filterCorrectParameterCount(Collection<GroovyResolveResult> candidates) {
PsiType[] argumentTypes = myArgumentTypes.getValue();
if (argumentTypes == null)
return ContainerUtil.newArrayList(candidates);
final List<GroovyResolveResult> result = ContainerUtil.newSmartList();
for (GroovyResolveResult candidate : candidates) {
if (candidate instanceof GroovyMethodResult) {
if (((GroovyMethodResult) candidate).getElement().getParameterList().getParametersCount() == argumentTypes.length) {
result.add(candidate);
}
} else {
result.add(candidate);
}
}
if (!result.isEmpty())
return result;
return ContainerUtil.newArrayList(candidates);
}
use of org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult in project intellij-community by JetBrains.
the class GroovyResolverProcessorImpl method collapseReflectedMethods.
private static List<GroovyResolveResult> collapseReflectedMethods(Collection<GroovyResolveResult> candidates) {
Set<GrMethod> visited = ContainerUtil.newHashSet();
List<GroovyResolveResult> collapsed = ContainerUtil.newArrayList();
for (GroovyResolveResult result : candidates) {
PsiElement element = result.getElement();
if (element instanceof GrReflectedMethod) {
GrMethod baseMethod = ((GrReflectedMethod) element).getBaseMethod();
if (visited.add(baseMethod)) {
collapsed.add(PsiImplUtil.reflectedToBase(result, baseMethod, (GrReflectedMethod) element));
}
} else {
collapsed.add(result);
}
}
return collapsed;
}
use of org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult in project intellij-community by JetBrains.
the class PropertyResolverProcessor method getCandidates.
@NotNull
@Override
public GroovyResolveResult[] getCandidates() {
//do not have more than one correct result. And if it exists it is the last
final List<GroovyResolveResult> candidates = getCandidatesInternal();
final int size = candidates.size();
if (size == 0)
return GroovyResolveResult.EMPTY_ARRAY;
GroovyResolveResult last = candidates.get(size - 1);
if (last.getElement() instanceof GrBindingVariable && size > 1) {
last = candidates.get(size - 2);
}
if (isCorrectLocalVarOrParam(last)) {
return new GroovyResolveResult[] { last };
}
for (GroovyResolveResult candidate : candidates) {
if (candidate.isStaticsOK()) {
return new GroovyResolveResult[] { candidate };
}
}
return candidates.toArray(new GroovyResolveResult[candidates.size()]);
}
Aggregations