Skip to content

Commit 3356756

Browse files
nicolasstuckiPanAeon
authored andcommitted
Improve rule for given declaration detecion
1 parent bc21156 commit 3356756

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

src/typescript/Scala.tmLanguage.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -707,17 +707,11 @@ export const scalaTmLanguage: TmLanguage = {
707707
name: 'meta.package.scala'
708708
},
709709
{
710-
match: `\\b(given)\\s+(as)\\s`,
710+
match: `\\b(given)\\b\\s*(?:\\b(as)\\b|(${backQuotedId}|(?!//|/\\*)${plainid})?)`,
711711
captures: {
712712
'1': { name: 'keyword.declaration.scala' },
713-
'2': { name: 'keyword.declaration.scala' }
714-
}
715-
},
716-
{
717-
match: `\\b(given)\\s+(${backQuotedId}|${plainid})?`,
718-
captures: {
719-
'1': { name: 'keyword.declaration.scala' },
720-
'2': { name: 'entity.name.declaration' }
713+
'2': { name: 'keyword.declaration.scala' },
714+
'3': { name: 'entity.name.declaration' }
721715
}
722716
}
723717
]

tests/unit/#103.test.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,21 @@
6767
// ^^^ constant.character.literal.scala
6868
// ^^^^ keyword.control.flow.scala
6969
// ^ constant.numeric.scala
70+
71+
given // this should be a comment
72+
// ^^^^^ keyword.declaration.scala
73+
// ^^ punctuation.definition.comment.scala
74+
// ^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.double-slash.scala
75+
as Foo
76+
// ^^ keyword.declaration.scala
77+
78+
given// this should be a comment
79+
// ^^^^^ keyword.declaration.scala
80+
// ^^ punctuation.definition.comment.scala
81+
// ^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.double-slash.scala
82+
83+
given /* this should be a comment */
84+
// ^^^^^ keyword.declaration.scala
85+
// ^^ punctuation.definition.comment.scala
86+
// ^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.block.scala
87+
// ^^ punctuation.definition.comment.scala

0 commit comments

Comments
 (0)