Keyword completion: add 'fun' after 'suspend' (KT-29038)

#KT-29038 Fixed
This commit is contained in:
Toshiaki Kameyama
2019-02-28 04:41:48 +03:00
committed by Nikolay Krasko
parent fd262bcd8d
commit dfd3947856
23 changed files with 28 additions and 24 deletions
@@ -63,7 +63,8 @@ object KeywordCompletion {
ANNOTATION_KEYWORD to CLASS_KEYWORD,
SEALED_KEYWORD to CLASS_KEYWORD,
LATEINIT_KEYWORD to VAR_KEYWORD,
CONST_KEYWORD to VAL_KEYWORD
CONST_KEYWORD to VAL_KEYWORD,
SUSPEND_KEYWORD to FUN_KEYWORD
)
private val KEYWORD_CONSTRUCTS = mapOf<KtKeywordToken, String>(
@@ -99,7 +100,10 @@ object KeywordCompletion {
for (keywordToken in ALL_KEYWORDS) {
var keyword = keywordToken.value
val nextKeyword = COMPOUND_KEYWORDS[keywordToken]
val nextKeyword = when {
keywordToken == SUSPEND_KEYWORD && ((position.containingFile as? KtFile)?.isScript() == true) -> null
else -> COMPOUND_KEYWORDS[keywordToken]
}
var applicableAsCompound = false
if (nextKeyword != null) {
fun PsiElement.isSpace() = this is PsiWhiteSpace && '\n' !in getText()
@@ -39,7 +39,7 @@ class MouseMovedEventArgs
// EXIST: tailrec
// EXIST: external
// EXIST: annotation class
// EXIST: suspend
// EXIST: suspend fun
// EXIST: typealias
// EXIST: expect
// EXIST: actual
+1 -1
View File
@@ -37,7 +37,7 @@ class AfterClasses {
// EXIST: external
// EXIST: annotation class
// EXIST: const val
// EXIST: suspend
// EXIST: suspend fun
// EXIST: typealias
// EXIST: expect
// EXIST: actual
@@ -41,6 +41,6 @@ class B {
// EXIST: annotation class
// EXIST: annotation class AfterClasses_LangLevel11
// EXIST: const val
// EXIST: suspend
// EXIST: suspend fun
// EXIST: typealias
// NOTHING_ELSE
+1 -1
View File
@@ -38,7 +38,7 @@ class A {
// EXIST: tailrec
// EXIST: external
// EXIST: annotation class
// EXIST: suspend
// EXIST: suspend fun
// EXIST: typealias
// EXIST: expect
// EXIST: actual
@@ -45,7 +45,7 @@ var a : Int
// EXIST: annotation class
// EXIST: annotation class GlobalPropertyAccessors
// EXIST: const val
// EXIST: suspend
// EXIST: suspend fun
// EXIST: typealias
// EXIST: expect
// EXIST: actual
@@ -24,7 +24,7 @@ annotation class Test {
// EXIST: tailrec
// EXIST: external
// EXIST: annotation class
// EXIST: suspend
// EXIST: suspend fun
// EXIST: typealias
// EXIST: expect
// EXIST: actual
+1 -1
View File
@@ -36,7 +36,7 @@ public class Test {
// EXIST: tailrec
// EXIST: external
// EXIST: annotation class
// EXIST: suspend
// EXIST: suspend fun
// EXIST: typealias
// EXIST: expect
// EXIST: actual
+1 -1
View File
@@ -30,7 +30,7 @@ class TestClass {
// EXIST: tailrec
// EXIST: external
// EXIST: annotation class
// EXIST: suspend
// EXIST: suspend fun
// EXIST: typealias
// EXIST: expect
// EXIST: actual
+1 -1
View File
@@ -24,7 +24,7 @@ enum class Test {
// EXIST: tailrec
// EXIST: external
// EXIST: annotation class
// EXIST: suspend
// EXIST: suspend fun
// EXIST: fun
// EXIST: typealias
// EXIST: expect
@@ -2,5 +2,5 @@ fun foo() {
val test : <caret>
}
// EXIST: suspend
// EXIST: suspend fun
// NOTHING_ELSE
+1 -1
View File
@@ -26,7 +26,7 @@ interface Test {
// EXIST: tailrec
// EXIST: external
// EXIST: annotation class
// EXIST: suspend
// EXIST: suspend fun
// EXIST: typealias
// EXIST: expect
// EXIST: actual
+1 -1
View File
@@ -28,7 +28,7 @@ object Test {
// EXIST: external
// EXIST: annotation class
// EXIST: const val
// EXIST: suspend
// EXIST: suspend fun
// EXIST: typealias
// EXIST: expect
// EXIST: actual
@@ -32,7 +32,7 @@ package Test
// EXIST: annotation class
// EXIST: annotation class InTopScopeAfterPackage
// EXIST: const val
// EXIST: suspend
// EXIST: suspend fun
// EXIST: typealias
// EXIST: expect
// EXIST: actual
+1 -1
View File
@@ -1,5 +1,5 @@
val a : <caret>
// EXIST: suspend
// EXIST: suspend fun
// NOTHING_ELSE
@@ -38,7 +38,7 @@ class Some {
// EXIST: tailrec
// EXIST: external
// EXIST: annotation class
// EXIST: suspend
// EXIST: suspend fun
// EXIST: typealias
// EXIST: expect
// EXIST: actual
@@ -38,7 +38,7 @@ class Some {
// EXIST: tailrec
// EXIST: external
// EXIST: annotation class
// EXIST: suspend
// EXIST: suspend fun
// EXIST: typealias
// EXIST: expect
// EXIST: actual
+1 -1
View File
@@ -36,7 +36,7 @@ class Some {
// EXIST: tailrec
// EXIST: external
// EXIST: annotation class
// EXIST: suspend
// EXIST: suspend fun
// EXIST: typealias
// EXIST: expect
// EXIST: actual
@@ -5,7 +5,7 @@ class Su() {
}
// EXIST: suspend
// EXIST: suspend fun
/* TODO: items below are not valid here */
// EXIST: class
@@ -5,7 +5,7 @@ class Su() {
}
// EXIST: suspend
// EXIST: suspend fun
/* TODO: items below are not valid here */
// EXIST: class
+1 -1
View File
@@ -31,7 +31,7 @@
// EXIST: annotation class
// EXIST: annotation class TopScope
// EXIST: const val
// EXIST: suspend
// EXIST: suspend fun
// EXIST: typealias
// EXIST: expect
// EXIST: actual
+1 -1
View File
@@ -24,7 +24,7 @@
// EXIST: external
// EXIST: annotation class
// EXIST: const val
// EXIST: suspend
// EXIST: suspend fun
// EXIST: typealias
// EXIST: expect
// EXIST: actual
+1 -1
View File
@@ -24,7 +24,7 @@
// EXIST: external
// EXIST: annotation class
// EXIST: const val
// EXIST: suspend
// EXIST: suspend fun
// EXIST: typealias
// EXIST: expect
// EXIST: actual