Skip to content

Commit 57b8ec8

Browse files
authored
Fix detection of imports with trailing comments (#76)
Thank you for your contribution
1 parent 559bd2f commit 57b8ec8

File tree

6 files changed

+22
-7
lines changed

6 files changed

+22
-7
lines changed

dist/Kotlin.JSON-tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@
453453
"imports": {
454454
"patterns": [
455455
{
456-
"match": "^\\s*(import)\\s+((?:[`][^$`]+[`]|[^` $.]+)(?:\\.(?:[`][^$`]+[`]|[^` $.]+))*)(?:\\s+(as)\\s+([`][^$`]+[`]|[^` $.]+))?$",
456+
"match": "^\\s*(import)\\s+((?:[`][^$`]+[`]|[^` $.]+)(?:\\.(?:[`][^$`]+[`]|[^` $.]+))*)(?:\\s+(as)\\s+([`][^$`]+[`]|[^` $.]+))?",
457457
"captures": {
458458
"1": {
459459
"name": "keyword.other.import.kotlin"

dist/Kotlin.YAML-tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ repository:
125125
imports:
126126
patterns:
127127
-
128-
match: '^\s*(import)\s+((?:[`][^$`]+[`]|[^` $.]+)(?:\.(?:[`][^$`]+[`]|[^` $.]+))*)(?:\s+(as)\s+([`][^$`]+[`]|[^` $.]+))?$'
128+
match: '^\s*(import)\s+((?:[`][^$`]+[`]|[^` $.]+)(?:\.(?:[`][^$`]+[`]|[^` $.]+))*)(?:\s+(as)\s+([`][^$`]+[`]|[^` $.]+))?'
129129
captures:
130130
'1': {name: keyword.other.import.kotlin}
131131
'2': {name: storage.modifier.import.kotlin}

dist/Kotlin.tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@
686686
<array>
687687
<dict>
688688
<key>match</key>
689-
<string>^\s*(import)\s+((?:[`][^$`]+[`]|[^` $.]+)(?:\.(?:[`][^$`]+[`]|[^` $.]+))*)(?:\s+(as)\s+([`][^$`]+[`]|[^` $.]+))?$</string>
689+
<string>^\s*(import)\s+((?:[`][^$`]+[`]|[^` $.]+)(?:\.(?:[`][^$`]+[`]|[^` $.]+))*)(?:\s+(as)\s+([`][^$`]+[`]|[^` $.]+))?</string>
690690
<key>captures</key>
691691
<dict>
692692
<key>1</key>

src/imports.YAML-tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ repository:
22
imports:
33
patterns:
44
-
5-
match: '^\s*(import)\s+((?:[`][^$`]+[`]|[^` $.]+)(?:\.(?:[`][^$`]+[`]|[^` $.]+))*)(?:\s+(as)\s+([`][^$`]+[`]|[^` $.]+))?$'
5+
match: '^\s*(import)\s+((?:[`][^$`]+[`]|[^` $.]+)(?:\.(?:[`][^$`]+[`]|[^` $.]+))*)(?:\s+(as)\s+([`][^$`]+[`]|[^` $.]+))?'
66
captures:
77
'1':
88
name: keyword.other.import.kotlin

src/literals.YAML-tmLanguage

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ repository:
7171
-
7272
include: '#string-content'
7373
repository:
74-
# https://kotlinlang.org/docs/strings.html#raw-strings
75-
# Raw strings do not contain escape sequences.
7674
raw-string-content:
7775
patterns:
7876
-

test/Imports.test.kt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,21 @@
3131
// ^ source.kotlin meta.import.kotlin
3232
// ^^ source.kotlin meta.import.kotlin keyword.other.kotlin
3333
// ^ source.kotlin meta.import.kotlin
34-
// ^^^^ source.kotlin meta.import.kotlin entity.name.type
34+
// ^^^^ source.kotlin meta.import.kotlin entity.name.type
35+
36+
import com.google.test.CommentedClass // comment
37+
//^^^^^^ source.kotlin meta.import.kotlin keyword.other.import.kotlin
38+
// ^ source.kotlin meta.import.kotlin
39+
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.kotlin meta.import.kotlin storage.modifier.import.kotlin
40+
// ^^ source.kotlin punctuation.definition.comment.kotlin comment.line.double-slash.kotlin
41+
42+
import com.google.test.CommentedClass /*comment*/ as Another
43+
//^^^^^^ source.kotlin meta.import.kotlin keyword.other.import.kotlin
44+
// ^ source.kotlin meta.import.kotlin
45+
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.kotlin meta.import.kotlin storage.modifier.import.kotlin
46+
// ^^ source.kotlin comment.block.kotlin punctuation.definition.comment.begin.kotlin
47+
// ^^ source.kotlin comment.block.kotlin punctuation.definition.comment.end.kotlin
48+
// ^ source.kotlin
49+
// ^^ source.kotlin keyword.operator.kotlin
50+
// ^ source.kotlin
51+
// ^^^^^^^ source.kotlin entity.name.type.class.kotlin

0 commit comments

Comments
 (0)