mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 04:51:24 +07:00
IDEA-134123 Reflection code completion generates Type....class instead of Type[].class for varargs
This commit is contained in:
@@ -23,9 +23,11 @@ import com.intellij.codeInsight.lookup.LookupElementBuilder;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.impl.source.PsiClassReferenceType;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiTypesUtil;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -169,7 +171,11 @@ public class JavaLangClassMemberReference extends PsiReferenceBase<PsiLiteralExp
|
||||
private static String getMethodTypes(PsiMethod method) {
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
for (PsiParameter parameter : method.getParameterList().getParameters()) {
|
||||
buf.append(", ").append(TypeConversionUtil.erasure(parameter.getType()).getPresentableText()).append(".class");
|
||||
PsiType type = TypeConversionUtil.erasure(parameter.getType());
|
||||
if (type instanceof PsiEllipsisType) {
|
||||
type = new PsiArrayType(((PsiEllipsisType)type).getComponentType());
|
||||
}
|
||||
buf.append(", ").append(type.getPresentableText()).append(".class");
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
class ForNameMethod {
|
||||
void foo() {
|
||||
Class.forName("Test").getMethod("va<caret>");
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public void vararg(String... b){}
|
||||
public void vararg2(String... b){}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
class ForNameMethod {
|
||||
void foo() {
|
||||
Class.forName("Test").getMethod("vararg<caret>", String[].class);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public void vararg(String... b){}
|
||||
public void vararg2(String... b){}
|
||||
}
|
||||
@@ -63,6 +63,10 @@ public class JavaReflectionCompletionTest extends LightFixtureCompletionTestCase
|
||||
doTest(2, "num", "num2", "num3");
|
||||
}
|
||||
|
||||
public void testVarargMethod() throws Exception {
|
||||
doTest(0, "vararg", "vararg2");
|
||||
}
|
||||
|
||||
public void testGenerics() throws Exception {
|
||||
myFixture.addFileToProject("a.properties", "foo=bar"); // check that property variants don't override reflection ones
|
||||
doTest(0, "foo");
|
||||
|
||||
Reference in New Issue
Block a user