mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
IDEA-126171
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
class VarArgs {
|
||||
private void g() {
|
||||
f<flown111>("d",1,2,3);
|
||||
}
|
||||
|
||||
void f(String value,int... <flown11>i) {
|
||||
v(value, <flown1>i);
|
||||
}
|
||||
|
||||
private void v(String value, int... <caret>ints) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
class VarArgs {
|
||||
private static void foo(String value, int...<flown11>ints) {
|
||||
System.out.println(value + " " + java.util.Arrays.asList(ints));
|
||||
int <caret>anInt = <flown1>ints[1];
|
||||
}
|
||||
|
||||
private static void bar(String value, int...<flown1111>ints) {
|
||||
foo(value, <flown111>ints);
|
||||
}
|
||||
|
||||
private static void baz(String value) {
|
||||
bar<flown11111>("d", <flown111111>2, <flown111112>3, <flown111113>4);
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
@@ -179,6 +179,8 @@ public class SliceBackwardTest extends SliceTestCase {
|
||||
public void testArrayElements() throws Exception { doTest();}
|
||||
public void testAnonArray() throws Exception { doTest();}
|
||||
public void testVarArgs() throws Exception { doTest();}
|
||||
public void testVarArgsAsAWhole() throws Exception { doTest();}
|
||||
public void testVarArgsPartial() throws Exception { doTest();}
|
||||
|
||||
public void testListTrackToArray() throws Exception { doTest();}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user