Skip to content

Commit

Permalink
Potental fix for numeric literal colorization (#603)
Browse files Browse the repository at this point in the history
* Added AppManager AppMemoryMonitor AppMemoryMonitorEvent coloring

* Potental fix for numeric literal colorization

* Better unit tests

* Added missing built ins for roCECStatus, roDeviceCrypto, roDsa, and roRemoteInfo

* Update src/grammar/brightscript.tmLanguage.spec.ts
  • Loading branch information
chrisdp authored Nov 14, 2024
1 parent 5851b34 commit ddbade2
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 2 deletions.
67 changes: 67 additions & 0 deletions src/grammar/brightscript.tmLanguage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,73 @@ import { standardizePath as s } from 'brighterscript';
const brightscriptTmlanguagePath = s`${__dirname}/../../syntaxes/brightscript.tmLanguage.json`;

describe('brightscript.tmlanguage.json', () => {
it('colors numerics correctly', async () => {
await testGrammar(`
var = 1
' ^ constant.numeric.brs
'^^^ entity.name.variable.local.brs
`);

await testGrammar(`
var = 1.1
' ^ constant.numeric.brs
' ^ constant.numeric.brs
'^^^ entity.name.variable.local.brs
`);

await testGrammar(`
var = .1
' ^ constant.numeric.brs
'^^^ entity.name.variable.local.brs
`);

await testGrammar(`
var = 0x2
' ^^^ constant.numeric.brs
'^^^ entity.name.variable.local.brs
`);

await testGrammar(`
var = 1.8e+308
' ^^^^^^^^ constant.numeric.brs
'^^^ entity.name.variable.local.brs
`);

await testGrammar(`
var = 0x2
' ^^^ constant.numeric.brs
'^^^ entity.name.variable.local.brs
`);

await testGrammar(`
var = 0%
' ^ source.brs
' ^ constant.numeric.brs
'^^^ entity.name.variable.local.brs
`);

await testGrammar(`
var = 0!
' ^ source.brs
' ^ constant.numeric.brs
'^^^ entity.name.variable.local.brs
`);

await testGrammar(`
var = 0#
' ^ source.brs
' ^ constant.numeric.brs
'^^^ entity.name.variable.local.brs
`);

await testGrammar(`
var = 0&
' ^ source.brs
' ^ constant.numeric.brs
'^^^ entity.name.variable.local.brs
`);
});

it('colors m, m.top, m.global, and super correctly', async () => {
await testGrammar(`
super.doSomething()
Expand Down
14 changes: 12 additions & 2 deletions syntaxes/brightscript.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@
{
"include": "#function_call"
},
{
"include": "#numeric_literal"
},
{
"include": "#object_properties"
},
Expand Down Expand Up @@ -581,8 +584,7 @@
]
},
{
"match": "\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?\\b",
"name": "constant.numeric.brs"
"include": "#numeric_literal"
},
{
"patterns": [
Expand All @@ -606,6 +608,14 @@
}
]
},
"numeric_literal": {
"patterns": [
{
"match": "\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?\\b",
"name": "constant.numeric.brs"
}
]
},
"comment": {
"patterns": [
{
Expand Down

0 comments on commit ddbade2

Please sign in to comment.