Skip to content

Commit

Permalink
Improve rule for given declaration detecion
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed Jul 7, 2020
1 parent b6e47aa commit 02fe701
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/typescript/Scala.tmLanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -707,17 +707,11 @@ export const scalaTmLanguage: TmLanguage = {
name: 'meta.package.scala'
},
{
match: `\\b(given)\\s+(as)\\s`,
match: `\\b(given)\\b\\s*(?:\\b(as)\\b|(${backQuotedId}|(?!//|/\\*)${plainid})?)`,
captures: {
'1': { name: 'keyword.declaration.scala' },
'2': { name: 'keyword.declaration.scala' }
}
},
{
match: `\\b(given)\\s+(${backQuotedId}|${plainid})?`,
captures: {
'1': { name: 'keyword.declaration.scala' },
'2': { name: 'entity.name.declaration' }
'2': { name: 'keyword.declaration.scala' },
'3': { name: 'entity.name.declaration' }
}
}
]
Expand Down
18 changes: 18 additions & 0 deletions tests/unit/#103.test.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,21 @@
// ^^^ constant.character.literal.scala
// ^^^^ keyword.control.flow.scala
// ^ constant.numeric.scala

given // this should be a comment
// ^^^^^ keyword.declaration.scala
// ^^ punctuation.definition.comment.scala
// ^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.double-slash.scala
as Foo
// ^^ keyword.declaration.scala

given// this should be a comment
// ^^^^^ keyword.declaration.scala
// ^^ punctuation.definition.comment.scala
// ^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.double-slash.scala

given /* this should be a comment */
// ^^^^^ keyword.declaration.scala
// ^^ punctuation.definition.comment.scala
// ^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.block.scala
// ^^ punctuation.definition.comment.scala

0 comments on commit 02fe701

Please sign in to comment.