KT-7344 Completion of second type argument in class instantiation does not work
#KT-7344 Fixed
This commit is contained in:
+5
-2
@@ -46,7 +46,6 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
|||||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||||
|
|
||||||
public class KotlinCompletionContributor : CompletionContributor() {
|
public class KotlinCompletionContributor : CompletionContributor() {
|
||||||
|
|
||||||
private val AFTER_NUMBER_LITERAL = psiElement().afterLeafSkipping(psiElement().withText(""), psiElement().withElementType(elementType().oneOf(JetTokens.FLOAT_LITERAL, JetTokens.INTEGER_LITERAL)))
|
private val AFTER_NUMBER_LITERAL = psiElement().afterLeafSkipping(psiElement().withText(""), psiElement().withElementType(elementType().oneOf(JetTokens.FLOAT_LITERAL, JetTokens.INTEGER_LITERAL)))
|
||||||
private val AFTER_INTEGER_LITERAL_AND_DOT = psiElement().afterLeafSkipping(psiElement().withText("."), psiElement().withElementType(elementType().oneOf(JetTokens.INTEGER_LITERAL)))
|
private val AFTER_INTEGER_LITERAL_AND_DOT = psiElement().afterLeafSkipping(psiElement().withText("."), psiElement().withElementType(elementType().oneOf(JetTokens.INTEGER_LITERAL)))
|
||||||
|
|
||||||
@@ -286,6 +285,11 @@ public class KotlinCompletionContributor : CompletionContributor() {
|
|||||||
|
|
||||||
private fun specialInTypeArgsDummyIdentifier(tokenBefore: PsiElement?): String? {
|
private fun specialInTypeArgsDummyIdentifier(tokenBefore: PsiElement?): String? {
|
||||||
if (tokenBefore == null) return null
|
if (tokenBefore == null) return null
|
||||||
|
|
||||||
|
if (tokenBefore.getParentOfType<JetTypeArgumentList>(true) != null) { // already parsed inside type argument list
|
||||||
|
return CompletionUtilCore.DUMMY_IDENTIFIER_TRIMMED // do not insert '$' to not break type argument list parsing
|
||||||
|
}
|
||||||
|
|
||||||
val pair = unclosedTypeArgListNameAndBalance(tokenBefore) ?: return null
|
val pair = unclosedTypeArgListNameAndBalance(tokenBefore) ?: return null
|
||||||
val (nameToken, balance) = pair
|
val (nameToken, balance) = pair
|
||||||
assert(balance > 0)
|
assert(balance > 0)
|
||||||
@@ -308,7 +312,6 @@ public class KotlinCompletionContributor : CompletionContributor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun unclosedTypeArgListNameAndBalance(tokenBefore: PsiElement): Pair<PsiElement, Int>? {
|
private fun unclosedTypeArgListNameAndBalance(tokenBefore: PsiElement): Pair<PsiElement, Int>? {
|
||||||
if (tokenBefore.getParentOfType<JetTypeArgumentList>(true) != null) return null // already parsed inside type argument list
|
|
||||||
val nameToken = findCallNameTokenIfInTypeArgs(tokenBefore) ?: return null
|
val nameToken = findCallNameTokenIfInTypeArgs(tokenBefore) ?: return null
|
||||||
val pair = unclosedTypeArgListNameAndBalance(nameToken)
|
val pair = unclosedTypeArgListNameAndBalance(nameToken)
|
||||||
if (pair == null) {
|
if (pair == null) {
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import java.util.HashMap
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
val v = HashMap<String, <caret>>
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXIST: String
|
||||||
|
// EXIST: java
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import java.util.HashMap
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
val v = HashMap<String, S<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXIST: String
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import java.util.HashMap
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
val v = HashMap<String, S<caret>>
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXIST: String
|
||||||
@@ -1403,6 +1403,24 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes
|
|||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/typeArgsOrNot/SecondTypeArg.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/typeArgsOrNot/SecondTypeArg.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("SecondTypeArg2.kt")
|
||||||
|
public void testSecondTypeArg2() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/typeArgsOrNot/SecondTypeArg2.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("SecondTypeArg3.kt")
|
||||||
|
public void testSecondTypeArg3() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/typeArgsOrNot/SecondTypeArg3.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("SecondTypeArg4.kt")
|
||||||
|
public void testSecondTypeArg4() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/typeArgsOrNot/SecondTypeArg4.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("idea/testData/completion/basic/common/visibility")
|
@TestMetadata("idea/testData/completion/basic/common/visibility")
|
||||||
|
|||||||
@@ -1403,6 +1403,24 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT
|
|||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/typeArgsOrNot/SecondTypeArg.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/typeArgsOrNot/SecondTypeArg.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("SecondTypeArg2.kt")
|
||||||
|
public void testSecondTypeArg2() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/typeArgsOrNot/SecondTypeArg2.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("SecondTypeArg3.kt")
|
||||||
|
public void testSecondTypeArg3() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/typeArgsOrNot/SecondTypeArg3.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("SecondTypeArg4.kt")
|
||||||
|
public void testSecondTypeArg4() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/typeArgsOrNot/SecondTypeArg4.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("idea/testData/completion/basic/common/visibility")
|
@TestMetadata("idea/testData/completion/basic/common/visibility")
|
||||||
|
|||||||
+1
@@ -17,6 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.idea.conversion.copy;
|
package org.jetbrains.kotlin.idea.conversion.copy;
|
||||||
|
|
||||||
import com.intellij.testFramework.TestDataPath;
|
import com.intellij.testFramework.TestDataPath;
|
||||||
|
import org.jetbrains.kotlin.test.InnerTestClasses;
|
||||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||||
import org.jetbrains.kotlin.test.JetTestUtils;
|
import org.jetbrains.kotlin.test.JetTestUtils;
|
||||||
import org.jetbrains.kotlin.test.TestMetadata;
|
import org.jetbrains.kotlin.test.TestMetadata;
|
||||||
|
|||||||
Reference in New Issue
Block a user