summaryrefslogtreecommitdiff
path: root/java/java-impl/src/com/intellij/slicer/SliceUtil.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/java-impl/src/com/intellij/slicer/SliceUtil.java')
-rw-r--r--java/java-impl/src/com/intellij/slicer/SliceUtil.java30
1 files changed, 22 insertions, 8 deletions
diff --git a/java/java-impl/src/com/intellij/slicer/SliceUtil.java b/java/java-impl/src/com/intellij/slicer/SliceUtil.java
index f27701a88c67..6d556b5f9681 100644
--- a/java/java-impl/src/com/intellij/slicer/SliceUtil.java
+++ b/java/java-impl/src/com/intellij/slicer/SliceUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -64,14 +64,25 @@ public class SliceUtil {
expression = ((PsiArrayAccessExpression)expression).getArrayExpression();
indexNesting++;
}
- if (expression instanceof PsiExpressionList && indexNesting != 0 && expression.getParent() instanceof PsiMethodCallExpression) {
+ PsiElement par = expression == null ? null : expression.getParent();
+ if (expression instanceof PsiExpressionList && par instanceof PsiMethodCallExpression) {
// expression list ends up here if we track varargs
- // unfold varargs list into individual expressions
- PsiExpression[] expressions = ((PsiExpressionList)expression).getExpressions();
- for (PsiExpression arg : expressions) {
- if (!handToProcessor(arg, processor, parent, parentSubstitutor, indexNesting -1, syntheticField)) return false;
+ PsiMethod method = ((PsiMethodCallExpression)par).resolveMethod();
+ if (method != null) {
+ int parametersCount = method.getParameterList().getParametersCount();
+ if (parametersCount != 0) {
+ // unfold varargs list into individual expressions
+ PsiExpression[] expressions = ((PsiExpressionList)expression).getExpressions();
+ if (indexNesting != 0) {
+ // should skip not-vararg arguments
+ for (int i = parametersCount-1; i < expressions.length; i++) {
+ PsiExpression arg = expressions[i];
+ if (!handToProcessor(arg, processor, parent, parentSubstitutor, indexNesting - 1, syntheticField)) return false;
+ }
+ }
+ return true;
+ }
}
- return true;
}
boolean needToReportDeclaration = false;
@@ -409,7 +420,6 @@ public class SliceUtil {
PsiType actualExpressionType;
if (actualParameterType instanceof PsiEllipsisType) {
passExpression = argumentList;
- //passExpression = createArrayInitializerFromExpressions(argumentList, ((PsiEllipsisType)actualType).getComponentType(), expressions);
actualExpressionType = expressions[paramSeqNo].getType();
}
else {
@@ -446,6 +456,10 @@ public class SliceUtil {
if (substituted == null) return true;
PsiType typeToCheck;
if (actualParameterType instanceof PsiEllipsisType) {
+ // there may be the case of passing the vararg argument to the other vararg method: foo(int... ints) { bar(ints); } bar(int... ints) {}
+ if (TypeConversionUtil.areTypesConvertible(substituted, actualParameterType)) {
+ return handToProcessor(expressions[paramSeqNo], processor, parent, combined, indexNesting, syntheticField);
+ }
typeToCheck = ((PsiEllipsisType)actualParameterType).getComponentType();
}
else {