mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-59103 Groovy: IllegalArgumentException at GroovyParameterInfoHandler.updateUI() on viewing Parameter Info of parameterless method in chained methods calls
This commit is contained in:
@@ -1394,7 +1394,7 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
}
|
||||
if (argumentTypes != null &&
|
||||
!PsiUtil.isApplicable(argumentTypes, method, methodResolveResult.getSubstitutor(),
|
||||
methodResolveResult.getCurrentFileResolveContext() instanceof GrMethodCallExpression, place)) {
|
||||
ResolveUtil.isInUseScope(methodResolveResult), place)) {
|
||||
|
||||
//check for implicit use of property getter which returns closure
|
||||
if (GroovyPropertyUtils.isSimplePropertyGetter(method)) {
|
||||
|
||||
+2
-2
@@ -152,7 +152,7 @@ public class GroovyParameterInfoHandler implements ParameterInfoHandler<GroovyPs
|
||||
for (int j = 0; j < parameters.length; j++) {
|
||||
parameterTypes[j] = parameters[j].getType();
|
||||
}
|
||||
if (resolveResult.getCurrentFileResolveContext() instanceof GrMethodCallExpression) {
|
||||
if (ResolveUtil.isInUseScope(resolveResult)) {
|
||||
parameterTypes = ArrayUtil.remove(parameterTypes, 0);
|
||||
}
|
||||
argTypes = PsiUtil.getArgumentTypes(place, false);
|
||||
@@ -294,7 +294,7 @@ public class GroovyParameterInfoHandler implements ParameterInfoHandler<GroovyPs
|
||||
final int currentParameter = context.getCurrentParameterIndex();
|
||||
|
||||
PsiParameter[] parms = method.getParameterList().getParameters();
|
||||
if (resolveResult.getCurrentFileResolveContext() instanceof GrMethodCallExpression) {
|
||||
if (ResolveUtil.isInUseScope(resolveResult)) {
|
||||
parms = ArrayUtil.remove(parms, 0);
|
||||
}
|
||||
int numParams = parms.length;
|
||||
|
||||
+3
-4
@@ -39,7 +39,6 @@ import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrThisReferenceExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAccessorMethod;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMember;
|
||||
@@ -219,7 +218,7 @@ public class CompleteReferenceExpression {
|
||||
private static GroovyResolveResult[] filterStaticsOK(GroovyResolveResult[] candidates) {
|
||||
List<GroovyResolveResult> result = new ArrayList<GroovyResolveResult>(candidates.length);
|
||||
for (GroovyResolveResult resolveResult : candidates) {
|
||||
if (resolveResult.isStaticsOK() || resolveResult.getCurrentFileResolveContext() instanceof GrMethodCallExpression) {
|
||||
if (resolveResult.isStaticsOK() || ResolveUtil.isInUseScope(resolveResult)) {
|
||||
result.add(resolveResult);
|
||||
}
|
||||
}
|
||||
@@ -261,11 +260,11 @@ public class CompleteReferenceExpression {
|
||||
PsiMethod method = (PsiMethod)element;
|
||||
String propName = null;
|
||||
PsiType propType = null;
|
||||
if (isSimplePropertyGetter(method, null, resolveResult.getCurrentFileResolveContext() instanceof GrMethodCallExpression)) {
|
||||
if (isSimplePropertyGetter(method, null, ResolveUtil.isInUseScope(resolveResult))) {
|
||||
propName = getPropertyNameByGetter(method);
|
||||
propType = PsiUtil.getSmartReturnType(method);
|
||||
}
|
||||
else if (isSimplePropertySetter(method, null, resolveResult.getCurrentFileResolveContext() instanceof GrMethodCallExpression)) {
|
||||
else if (isSimplePropertySetter(method, null, ResolveUtil.isInUseScope(resolveResult))) {
|
||||
propName = getPropertyName(method);
|
||||
propType = method.getParameterList().getParameters()[0].getType();
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgument
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrApplicationStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrCallExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression;
|
||||
@@ -487,4 +488,18 @@ public class ResolveUtil {
|
||||
}
|
||||
return constructors;
|
||||
}
|
||||
|
||||
public static boolean isInUseScope(GroovyResolveResult resolveResult) {
|
||||
final GroovyPsiElement context = resolveResult.getCurrentFileResolveContext();
|
||||
if (context instanceof GrMethodCall) {
|
||||
final GrExpression expression = ((GrMethodCall)context).getInvokedExpression();
|
||||
if (expression instanceof GrReferenceExpression) {
|
||||
final PsiElement resolved = ((GrReferenceExpression)expression).resolve();
|
||||
if (resolved instanceof GrGdkMethod && "use".equals(((GrGdkMethod)resolved).getStaticMethod().getName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user