[groovy] make SubstitutorComputer.obtainSubstitutor() accept resolveContext as PsiElement

This commit is contained in:
Daniil Ovchinnikov
2015-12-10 16:48:00 +03:00
parent 95e4dc18a5
commit f039ca52aa
4 changed files with 8 additions and 7 deletions
@@ -106,11 +106,11 @@ public class AccessorResolverProcessor extends MethodResolverProcessor {
PsiSubstitutor substitutor = state.get(PsiSubstitutor.KEY);
if (substitutor == null) substitutor = PsiSubstitutor.EMPTY;
final PsiElement resolveContext = state.get(RESOLVE_CONTEXT);
if (mySubstitutorComputer != null) {
substitutor = mySubstitutorComputer.obtainSubstitutor(substitutor, method, state);
substitutor = mySubstitutorComputer.obtainSubstitutor(substitutor, method, resolveContext);
}
boolean isAccessible = isAccessible(method);
final PsiElement resolveContext = state.get(RESOLVE_CONTEXT);
final SpreadState spreadState = state.get(SpreadState.SPREAD_STATE);
boolean isStaticsOK = isStaticsOK(method, resolveContext, false);
final GroovyMethodResult candidate = new GroovyMethodResult(
@@ -137,7 +137,7 @@ public class MethodResolverProcessor extends ResolverProcessor<GroovyMethodResul
if (substitutor == null) substitutor = PsiSubstitutor.EMPTY;
return myByShape ? substitutor
: mySubstitutorComputer.obtainSubstitutor(substitutor, method, state);
: mySubstitutorComputer.obtainSubstitutor(substitutor, method, state.get(RESOLVE_CONTEXT));
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -112,7 +112,9 @@ public class SubstitutorComputer {
return false;
}
public PsiSubstitutor obtainSubstitutor(PsiSubstitutor substitutor, PsiMethod method, ResolveState state) {
public PsiSubstitutor obtainSubstitutor(@NotNull PsiSubstitutor substitutor,
@NotNull PsiMethod method,
@Nullable PsiElement resolveContext) {
final PsiTypeParameter[] typeParameters = method.getTypeParameters();
if (myTypeArguments.length == typeParameters.length) {
for (int i = 0; i < typeParameters.length; i++) {
@@ -125,7 +127,6 @@ public class SubstitutorComputer {
if (myArgumentTypes != null && method.hasTypeParameters()) {
PsiType[] argTypes = myArgumentTypes;
final PsiElement resolveContext = state.get(ClassHint.RESOLVE_CONTEXT);
if (method instanceof GrGdkMethod) {
//type inference should be performed from static method
PsiType[] newArgTypes = PsiType.createArray(argTypes.length + 1);
@@ -454,7 +454,7 @@ public class CompleteReferenceExpression {
PsiSubstitutor substitutor = state.get(PsiSubstitutor.KEY);
if (substitutor == null) substitutor = PsiSubstitutor.EMPTY;
if (element instanceof PsiMethod) {
substitutor = mySubstitutorComputer.obtainSubstitutor(substitutor, (PsiMethod)element, state);
substitutor = mySubstitutorComputer.obtainSubstitutor(substitutor, (PsiMethod)element, resolveContext);
}
consume(new GroovyResolveResultImpl(namedElement, resolveContext, spreadState, substitutor, isAccessible, isStaticsOK));