Skip to content

Commit

Permalink
Merge pull request #176 from nicolasstucki/quotes
Browse files Browse the repository at this point in the history
Identify quotes/splices start as the start of a normal block
  • Loading branch information
MaximeKjaer authored Dec 17, 2020
2 parents 69fe540 + be95818 commit b2bcaaa
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/typescript/Scala.tmLanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,16 @@ export const scalaTmLanguage: TmLanguage = {
]
},
'scala-quoted': {
match: "('\\{|'\\[)(?!')",
name: 'constant.other.quoted.scala'
patterns: [
{ // Start of `'{ .. }` or `${ .. }`
match: "['$]\\{(?!')",
name: 'punctuation.section.block.begin.scala'
},
{ // Start of `'[ .. ]`
match: "'\\[(?!')",
name: 'meta.bracket.scala'
}
]
},
'xml-doublequotedString': {
end: '"',
Expand Down
20 changes: 18 additions & 2 deletions tests/unit/quoted.test.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
// SYNTAX TEST "source.scala"

'{ 2 }
// ^^ constant.other.quoted.scala
// ^^ punctuation.section.block.begin.scala
// ^ constant.numeric.scala
// ^ punctuation.section.block.end.scala

'[ String ]
// ^^ constant.other.quoted.scala
// ^^ meta.bracket.scala
// ^^^^^^ entity.name.class
// ^ meta.bracket.scala


${ 1 }
// ^^ punctuation.section.block.begin.scala
// ^ constant.numeric.scala
// ^ punctuation.section.block.end.scala

case '{ x } =>
// ^^^^ keyword.control.flow.scala
// ^^ punctuation.section.block.begin.scala
// ^ punctuation.section.block.end.scala

case '[ T ] =>
// ^^^^ keyword.control.flow.scala
// ^^ meta.bracket.scala
// ^ meta.bracket.scala

0 comments on commit b2bcaaa

Please sign in to comment.