Skip to content

Stop splitting common operators #275

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 8 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Simplify operators
Instead of dancing around around special operators
we can just enumerate them now. This fixes a lot of
edge cases.
  • Loading branch information
Jentsch committed Oct 11, 2024
commit 2a4b6b5fe396c878cd794da9e90bca50f75356a2
68 changes: 46 additions & 22 deletions src/typescript/Scala.tmLanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -676,31 +676,55 @@ export const scalaTmLanguage: TmLanguage = {
}
}
},
{ // Higher precedence than other kinds of operators to prevent
// decomposition of operators like ->
match: `(<-|←|->|→|=>|⇒|\\?|\\:|@|\\^)+${opchar}*`,
{ // Operators with three or more characters
match: `(${opchar}${opchar}${opchar}+)`,
name: 'keyword.operator.scala'
},
{ // The 'special' below operators directly follower by another symbol
// are just operators for example +:, /:, ++ and ==>
match: `(\\-|\\+|\\*|/(?![/*])|%|~|==|!=|<=|>=|<>)${opchar}+`,
name: 'keyword.operator.scala'
},
{
match: '(==?|!=|<=|>=|<>|<|>)',
name: 'keyword.operator.comparison.scala'
},
{
match: '(\\-|\\+|\\*|/(?![/*])|%|~)',
name: 'keyword.operator.arithmetic.scala'
},
{
match: `(?<!${opchar}|_)(!|&&|\\|\\|)(?!${opchar})`,
name: 'keyword.operator.logical.scala'
{ // Operators with two characters
match: `(${opchar}${opchar}|\\\\${opchar})`,
captures: {
'1': {
patterns: [
{
match: '(\\|\\||&&)',
name: 'keyword.operator.logical.scala'
},
{
match: '(\\!=|==|\\<=|>=)',
name: 'keyword.operator.comparison.scala'
},
{
match: '..',
name: 'keyword.operator.scala'
}
]
}
}
},
{ // Lower precedence than logical || operator
match: `(\\|)${opchar}*`,
name: 'keyword.operator.scala'
{ // Operators with one character
match: `(?<!${letter}_)(${opchar})`,
captures: {
'1': {
patterns: [
{
match: '(\\!)',
name: 'keyword.operator.logical.scala'
},
{
match: '(\\*|-|\\+|/|%|~)',
name: 'keyword.operator.arithmetic.scala'
},
{
match: '(=|\\<|>)',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here I think we shouln't match =, as a single = doesn't compare but defines things.

name: 'keyword.operator.comparison.scala'
},
{
match: '.',
name: 'keyword.operator.scala'
}
]
}
}
}
]
},
Expand Down
Loading