Revert 06215ca932
It led to parameter names missing in parameter info and completion for compiled java code used from kotlin See KT-11039
This commit is contained in:
+2
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 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.
|
||||
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.load.java.structure.impl;
|
||||
import com.intellij.psi.PsiAnnotationOwner;
|
||||
import com.intellij.psi.PsiParameter;
|
||||
import com.intellij.psi.impl.compiled.ClsParameterImpl;
|
||||
import com.intellij.psi.impl.java.stubs.impl.PsiParameterStubImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities;
|
||||
@@ -86,7 +85,7 @@ public class JavaValueParameterImpl extends JavaElementImpl<PsiParameter>
|
||||
@Nullable
|
||||
public Name getName() {
|
||||
PsiParameter psi = getPsi();
|
||||
if (isParameterWithAutoGeneratedName(psi)) {
|
||||
if (psi instanceof ClsParameterImpl && ((ClsParameterImpl) psi).isAutoGeneratedName()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -94,11 +93,6 @@ public class JavaValueParameterImpl extends JavaElementImpl<PsiParameter>
|
||||
return name == null ? null : Name.identifier(name);
|
||||
}
|
||||
|
||||
private static boolean isParameterWithAutoGeneratedName(PsiParameter psi) {
|
||||
// see com.intellij.psi.impl.compiled.ClsParameterImpl.calcName()
|
||||
return psi instanceof ClsParameterImpl && ((PsiParameterStubImpl) ((ClsParameterImpl) psi).getStub()).isAutoGeneratedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public JavaType getType() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 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.
|
||||
@@ -426,7 +426,7 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
testClass<AbstractParameterInfoTest>() {
|
||||
model("parameterInfo", recursive = true)
|
||||
model("parameterInfo", recursive = true, excludeDirs = listOf("withLib/sharedLib"))
|
||||
}
|
||||
|
||||
testClass<AbstractKotlinGotoTest>() {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package p;
|
||||
|
||||
public class JavaClass {
|
||||
public void foo(int myParamName1, String myParamName2) {}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package test
|
||||
|
||||
|
||||
fun main() {
|
||||
p.JavaClass().foo(<caret>)
|
||||
}
|
||||
|
||||
/*
|
||||
Text: (<highlight>myParamName1: Int</highlight>, myParamName2: String!), Disabled: false, Strikeout: false, Green: true
|
||||
*/
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 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.
|
||||
@@ -21,18 +21,31 @@ import com.intellij.codeInsight.hint.ShowParameterInfoHandler
|
||||
import com.intellij.psi.PsiDocumentManager
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiWhiteSpace
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||
import org.jetbrains.kotlin.idea.test.JdkAndMockLibraryProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||
import org.jetbrains.kotlin.idea.test.ProjectDescriptorWithStdlibSources
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.psiUtil.allChildren
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.TestMetadata
|
||||
import org.junit.Assert
|
||||
|
||||
abstract class AbstractParameterInfoTest : LightCodeInsightFixtureTestCase() {
|
||||
override fun getProjectDescriptor() = ProjectDescriptorWithStdlibSources.INSTANCE
|
||||
override fun getProjectDescriptor(): LightProjectDescriptor {
|
||||
val root = KotlinTestUtils.getTestsRoot(this.javaClass)
|
||||
if (root.endsWith("Lib")) {
|
||||
return JdkAndMockLibraryProjectDescriptor(
|
||||
"$root/sharedLib", true, true, false, false
|
||||
)
|
||||
|
||||
}
|
||||
return ProjectDescriptorWithStdlibSources.INSTANCE
|
||||
}
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.util.regex.Pattern;
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class ParameterInfoTestGenerated extends AbstractParameterInfoTest {
|
||||
public void testAllFilesPresentInParameterInfo() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/parameterInfo"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/parameterInfo"), Pattern.compile("^(.+)\\.kt$"), true, "withLib/sharedLib");
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/parameterInfo/arrayAccess")
|
||||
@@ -361,4 +361,19 @@ public class ParameterInfoTestGenerated extends AbstractParameterInfoTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/parameterInfo/withLib")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class WithLib extends AbstractParameterInfoTest {
|
||||
public void testAllFilesPresentInWithLib() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/parameterInfo/withLib"), Pattern.compile("^(.+)\\.kt$"), true, "sharedLib");
|
||||
}
|
||||
|
||||
@TestMetadata("useJavaFromLib.kt")
|
||||
public void testUseJavaFromLib() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/parameterInfo/withLib/useJavaFromLib.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user