Skip to content

Fix quoted with spaces #250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions src/typescript/Scala.tmLanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,17 +299,14 @@ export const scalaTmLanguage: TmLanguage = {
{
include: '#constants'
},
{
include: '#scala-symbol'
},
{
include: '#singleton-type'
},
{
include: '#inline'
},
{
include: '#scala-quoted'
include: '#scala-quoted-or-symbol'
},
{
include: '#char-literal'
Expand Down Expand Up @@ -710,16 +707,31 @@ export const scalaTmLanguage: TmLanguage = {
}
]
},
'scala-quoted': {
'scala-quoted-or-symbol': {
patterns: [
{ // Start of `'{ .. }` or `${ .. }`
match: "['$]\\{(?!')",
name: 'punctuation.section.block.begin.scala'
{ // `'xyz`
match: `(')((?>${plainid}))(?!')`,
captures: {
'1': {
name: 'keyword.control.flow.staging.scala constant.other.symbol.scala'
},
'2': {
name: 'constant.other.symbol.scala'
}
}
},
{ // Start of `'{ .. }`
match: `'(?=\\s*\\{(?!'))`,
name: 'keyword.control.flow.staging.scala'
},
{ // Start of `'[ .. ]`
match: "'\\[(?!')",
name: 'meta.bracket.scala'
}
match: "'(?=\\s*\\[(?!'))",
name: 'keyword.control.flow.staging.scala'
},
{ // Start of `${ .. }`
match: "\\$(?=\\s*\\{)",
name: 'keyword.control.flow.staging.scala'
},
]
},
'xml-doublequotedString': {
Expand Down Expand Up @@ -911,10 +923,6 @@ export const scalaTmLanguage: TmLanguage = {
}
}
},
'scala-symbol': {
match: `(?>'${plainid})(?!')`,
name: 'constant.other.symbol.scala'
},
'curly-braces': {
begin: '\\{',
end: '\\}',
Expand Down
2 changes: 1 addition & 1 deletion syntaxes/Scala.tmLanguage.json

Large diffs are not rendered by default.

15 changes: 10 additions & 5 deletions tests/snap/lexical.test.scala.snap
Original file line number Diff line number Diff line change
Expand Up @@ -378,15 +378,20 @@
> ('x, 'X, 'αρετη, '=, '+ )
#^^^^ source.scala
# ^ source.scala meta.bracket.scala
# ^^ source.scala constant.other.symbol.scala
# ^ source.scala keyword.control.flow.staging.scala constant.other.symbol.scala
# ^ source.scala constant.other.symbol.scala
# ^^ source.scala
# ^^ source.scala constant.other.symbol.scala
# ^ source.scala keyword.control.flow.staging.scala constant.other.symbol.scala
# ^ source.scala constant.other.symbol.scala
# ^^ source.scala
# ^^^^^^ source.scala constant.other.symbol.scala
# ^ source.scala keyword.control.flow.staging.scala constant.other.symbol.scala
# ^^^^^ source.scala constant.other.symbol.scala
# ^^ source.scala
# ^^ source.scala constant.other.symbol.scala
# ^ source.scala keyword.control.flow.staging.scala constant.other.symbol.scala
# ^ source.scala constant.other.symbol.scala
# ^^ source.scala
# ^^ source.scala constant.other.symbol.scala
# ^ source.scala keyword.control.flow.staging.scala constant.other.symbol.scala
# ^ source.scala constant.other.symbol.scala
# ^ source.scala
# ^ source.scala meta.bracket.scala
>}
Expand Down
1 change: 1 addition & 0 deletions tests/unit/lexical.test.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ object ExampleIdentifiers {
// ^^^^^^^^^^^^^ variable.stable.declaration.scala
val __system = 3
// ^^^^^^^^ variable.stable.declaration.scala

val _MAX_LEN_ = 3
// ^^^^^^^^^ variable.stable.declaration.scala
}
Expand Down
33 changes: 28 additions & 5 deletions tests/unit/quoted.test.scala
Original file line number Diff line number Diff line change
@@ -1,27 +1,50 @@
// SYNTAX TEST "source.scala"

'x
// ^ keyword.control.flow.staging.scala constant.other.symbol.scala
// ^ constant.other.symbol.scala
'{ 2 }
// ^^ punctuation.section.block.begin.scala
// ^ keyword.control.flow.staging.scala
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, should { have some kind of scope like in imports/exports? (for example we have meta.export.scala meta.export.selector.scala meta.bracket.scala) Or it doesn't really matter since braces are anyway interpreted correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{ have punctuation.section.block.begin.scala and [ have meta.bracket.scala.

I updated the tests

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

// ^ punctuation.section.block.begin.scala
// ^ constant.numeric.scala
// ^ punctuation.section.block.end.scala

' { 2 }
// ^ keyword.control.flow.staging.scala
// ^ punctuation.section.block.begin.scala
// ^ constant.numeric.scala
// ^ punctuation.section.block.end.scala

'
// ^ punctuation.definition.character.begin.scala
{ }

'[ String ]
// ^^ meta.bracket.scala
// ^ keyword.control.flow.staging.scala
// ^ meta.bracket.scala
// ^^^^^^ entity.name.class
// ^ meta.bracket.scala

' [ String ]
// ^ keyword.control.flow.staging.scala
// ^ meta.bracket.scala
// ^^^^^^ entity.name.class
// ^ meta.bracket.scala

${ 1 }
// ^^ punctuation.section.block.begin.scala
// ^ keyword.control.flow.staging.scala
// ^ punctuation.section.block.begin.scala
// ^ constant.numeric.scala
// ^ punctuation.section.block.end.scala

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

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