KT-20166: Replace type name when caret is at the end of param name
When caret is at the end ('f<caret>: Foo'), tokenAt was COLON,
not IDENTIFIER
#KT-20166 fixed
This commit is contained in:
+3
-1
@@ -131,7 +131,9 @@ class KotlinCompletionContributor : CompletionContributor() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tokenAt.node.elementType == KtTokens.IDENTIFIER) {
|
// IDENTIFIER when 'f<caret>oo: Foo'
|
||||||
|
// COLON when 'foo<caret>: Foo'
|
||||||
|
if (tokenAt.node.elementType == KtTokens.IDENTIFIER || tokenAt.node.elementType == KtTokens.COLON) {
|
||||||
val parameter = tokenAt.parent as? KtParameter
|
val parameter = tokenAt.parent as? KtParameter
|
||||||
if (parameter != null) {
|
if (parameter != null) {
|
||||||
context.offsetMap.addOffset(VariableOrParameterNameWithTypeCompletion.REPLACEMENT_OFFSET, parameter.endOffset)
|
context.offsetMap.addOffset(VariableOrParameterNameWithTypeCompletion.REPLACEMENT_OFFSET, parameter.endOffset)
|
||||||
|
|||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
class Foo
|
||||||
|
|
||||||
|
fun f(f<caret>: Foo)
|
||||||
|
|
||||||
|
// ELEMENT_TEXT: foo: Foo
|
||||||
|
// CHAR: '\t'
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
class Foo
|
||||||
|
|
||||||
|
fun f(foo: Foo)
|
||||||
|
|
||||||
|
// ELEMENT_TEXT: foo: Foo
|
||||||
|
// CHAR: '\t'
|
||||||
+6
@@ -698,6 +698,12 @@ public class BasicCompletionHandlerTestGenerated extends AbstractBasicCompletion
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("TabReplace3.kt")
|
||||||
|
public void testTabReplace3() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/parameterNameAndType/TabReplace3.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("TypeParameter.kt")
|
@TestMetadata("TypeParameter.kt")
|
||||||
public void testTypeParameter() throws Exception {
|
public void testTypeParameter() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/parameterNameAndType/TypeParameter.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/parameterNameAndType/TypeParameter.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user