Completion for "file" keyword in annotations
This commit is contained in:
@@ -45,7 +45,10 @@ object KeywordCompletion {
|
|||||||
.filter { it !in NON_ACTUAL_KEYWORDS }
|
.filter { it !in NON_ACTUAL_KEYWORDS }
|
||||||
.map { it as JetKeywordToken }
|
.map { it as JetKeywordToken }
|
||||||
|
|
||||||
private val KEYWORD_TO_DUMMY_POSTFIX = mapOf(OUT_KEYWORD to " X")
|
private val KEYWORD_TO_DUMMY_POSTFIX = mapOf(
|
||||||
|
OUT_KEYWORD to " X",
|
||||||
|
FILE_KEYWORD to ":"
|
||||||
|
)
|
||||||
|
|
||||||
public fun complete(position: PsiElement, prefix: String, consumer: (LookupElement) -> Unit) {
|
public fun complete(position: PsiElement, prefix: String, consumer: (LookupElement) -> Unit) {
|
||||||
if (!GENERAL_FILTER.isAcceptable(position, position)) return
|
if (!GENERAL_FILTER.isAcceptable(position, position)) return
|
||||||
|
|||||||
+5
-1
@@ -42,7 +42,11 @@ public object KotlinKeywordInsertHandler : InsertHandler<LookupElement> {
|
|||||||
DYNAMIC_KEYWORD).map { it.getValue() }
|
DYNAMIC_KEYWORD).map { it.getValue() }
|
||||||
|
|
||||||
override fun handleInsert(context: InsertionContext, item: LookupElement) {
|
override fun handleInsert(context: InsertionContext, item: LookupElement) {
|
||||||
if (item.getLookupString() !in NO_SPACE_AFTER) {
|
val keyword = item.getLookupString()
|
||||||
|
if (keyword == FILE_KEYWORD.getValue()) {
|
||||||
|
WithTailInsertHandler.colonTail().postHandleInsert(context, item)
|
||||||
|
}
|
||||||
|
else if (keyword !in NO_SPACE_AFTER) {
|
||||||
WithTailInsertHandler.spaceTail().postHandleInsert(context, item)
|
WithTailInsertHandler.spaceTail().postHandleInsert(context, item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,5 +91,6 @@ class WithTailInsertHandler(val tailText: String,
|
|||||||
fun elseTail() = WithTailInsertHandler("else", spaceBefore = true, spaceAfter = true)
|
fun elseTail() = WithTailInsertHandler("else", spaceBefore = true, spaceAfter = true)
|
||||||
fun eqTail() = WithTailInsertHandler("=", spaceBefore = true, spaceAfter = true) /*TODO: use code style options*/
|
fun eqTail() = WithTailInsertHandler("=", spaceBefore = true, spaceAfter = true) /*TODO: use code style options*/
|
||||||
fun spaceTail() = WithTailInsertHandler(" ", spaceBefore = false, spaceAfter = false, overwriteText = false)
|
fun spaceTail() = WithTailInsertHandler(" ", spaceBefore = false, spaceAfter = false, overwriteText = false)
|
||||||
|
fun colonTail() = WithTailInsertHandler(":", spaceBefore = false, spaceAfter = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
[fi<caret>]
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
[file: <caret>]
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
[<caret>]
|
||||||
|
|
||||||
|
// EXIST: file
|
||||||
|
// NUMBER: 1
|
||||||
@@ -102,6 +102,12 @@ public class KeywordCompletionTestGenerated extends AbstractKeywordCompletionTes
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("FileKeyword.kt")
|
||||||
|
public void testFileKeyword() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/keywords/FileKeyword.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("GlobalPropertyAccessors.kt")
|
@TestMetadata("GlobalPropertyAccessors.kt")
|
||||||
public void testGlobalPropertyAccessors() throws Exception {
|
public void testGlobalPropertyAccessors() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/keywords/GlobalPropertyAccessors.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/keywords/GlobalPropertyAccessors.kt");
|
||||||
|
|||||||
+6
@@ -42,6 +42,12 @@ public class KeywordCompletionHandlerTestGenerated extends AbstractKeywordComple
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("FileKeyword.kt")
|
||||||
|
public void testFileKeyword() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/handlers/keywords/FileKeyword.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("NoSpaceAfterNull.kt")
|
@TestMetadata("NoSpaceAfterNull.kt")
|
||||||
public void testNoSpaceAfterNull() throws Exception {
|
public void testNoSpaceAfterNull() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/handlers/keywords/NoSpaceAfterNull.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/handlers/keywords/NoSpaceAfterNull.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user