From 02fe701695b14e6b982628ae40731147e5141c2e Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 7 Jul 2020 08:52:59 +0200 Subject: [PATCH] Improve rule for `given` declaration detecion --- src/typescript/Scala.tmLanguage.ts | 12 +++--------- tests/unit/#103.test.scala | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/typescript/Scala.tmLanguage.ts b/src/typescript/Scala.tmLanguage.ts index eb31248..82f0ca0 100644 --- a/src/typescript/Scala.tmLanguage.ts +++ b/src/typescript/Scala.tmLanguage.ts @@ -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' } } } ] diff --git a/tests/unit/#103.test.scala b/tests/unit/#103.test.scala index dc00bbb..df54789 100644 --- a/tests/unit/#103.test.scala +++ b/tests/unit/#103.test.scala @@ -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