Skip to content

Commit

Permalink
Adds syntax highlighting for alias statements
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron committed May 13, 2024
1 parent 4facc56 commit ee0c0ae
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/grammar/brightscript.tmLanguage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,32 @@ import { standardizePath as s } from 'brighterscript';
const brightscriptTmlanguagePath = s`${__dirname}/../../syntaxes/brightscript.tmLanguage.json`;

describe('brightscript.tmlanguage.json', () => {
it('colors alias statement properly', async () => {
await testGrammar(`
alias alpha = beta
'^^^^ entity.name.variable.local.brs
'^ keyword.operator.assignment.brs
'^^^^^ entity.name.variable.brs
'^^^^^ keyword.declaration.alias.brs
`);

await testGrammar(`
alias alpha=beta
'^^^^ entity.name.variable.local.brs
'^ keyword.operator.assignment.brs
'^^^^^ entity.name.variable.brs
'^^^^^ keyword.declaration.alias.brs
`);

await testGrammar(`
alias alpha = beta.charlie.delta
'^^^^ entity.name.variable.local.brs
'^ keyword.operator.assignment.brs
'^^^^^ entity.name.variable.brs
'^^^^^ keyword.declaration.alias.brs
`);
});

it('colors normal conditional compile statements properly', async () => {
await testGrammar(`
#if true
Expand Down
17 changes: 17 additions & 0 deletions syntaxes/brightscript.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
{
"include": "#import_statement"
},
{
"include": "#alias_statement"
},
{
"include": "#namespace_declaration"
},
Expand Down Expand Up @@ -393,6 +396,20 @@
}
}
},
"alias_statement": {
"match": "(?i:(alias)\\s+([a-z0-9_]+)\\s*(=)\\s*)",
"captures": {
"1": {
"name": "keyword.declaration.alias.brs"
},
"2": {
"name": "entity.name.variable.brs"
},
"3": {
"name": "keyword.operator.assignment.brs"
}
}
},
"namespace_declaration": {
"begin": "(?i:(namespace))\\s+",
"beginCaptures": {
Expand Down

0 comments on commit ee0c0ae

Please sign in to comment.