Skip to content

Commit

Permalink
Fix iface syntax highlighting for comments & funcs (#489)
Browse files Browse the repository at this point in the history
* Fix iface syntax highlighting for comments & funcs

* Upgrade roku-debug to fix typedef issues
  • Loading branch information
TwitchBronBron authored Jun 8, 2023
1 parent 4121aee commit 788c623
Show file tree
Hide file tree
Showing 4 changed files with 190 additions and 25 deletions.
81 changes: 74 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"node-ssdp": "^4.0.0",
"postman-request": "^2.88.1-postman.32",
"pretty-bytes": "^5.6.0",
"roku-debug": "^0.19.0",
"roku-debug": "^0.19.1",
"roku-deploy": "^3.10.2",
"roku-test-automation": "^2.0.0-beta.19",
"semver": "^7.1.3",
Expand Down
30 changes: 30 additions & 0 deletions src/grammar/brightscript.tmLanguage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,36 @@ describe('brightscript.tmlanguage.json', () => {
`);
});

it('handles comments following interface fields', async () => {
await testGrammar(`
interface Person
name as string 'this is a comment
' ^^^^^^^^^^^^^^^^^^ punctuation.definition.comment.brs
' ^^^^^^ storage.type.brs
' ^^ keyword.control.as.brs
'^^ variable.object.property.brs
name as string
' ^^^^^^ storage.type.brs
' ^^ keyword.control.as.brs
'^^ variable.object.property.brs
`);
});

it('handles interface function with return type', async () => {
await testGrammar(`
interface Person
sub test() as string 'this is a comment
' ^^^^^^^^^^^^^^^^^ punctuation.definition.comment.brs
' ^^^^^^ storage.type.brs
' ^^ keyword.control.as.brs
' ^ punctuation.definition.parameters.end.brs
' ^ punctuation.definition.parameters.begin.brs
' ^^^^ entity.name.function.member.brs
'^^^ storage.type.function.brs
`);
});

it.skip('handles `as Function` parameters properly', async () => {
await testGrammar(`
function getStyle(builderFunc as Function, processorFunc as Function) as object
Expand Down
102 changes: 85 additions & 17 deletions syntaxes/brightscript.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@
"name": "punctuation.definition.comment.brs"
}
},
"match": "^\\s*?(?i:rem\\s).*$\\n?",
"match": "^\\s*?(?i:rem\\s.*)$",
"name": "comment.line.rem.brs"
},
"apostrophe_comment": {
Expand All @@ -607,7 +607,7 @@
"name": "punctuation.definition.comment.brs"
}
},
"match": "(').*$\\n?",
"match": "('[^\\r\\n]*)$",
"name": "comment.line.apostrophe.brs"
},
"keyword_logical_operator": {
Expand Down Expand Up @@ -730,21 +730,10 @@
"include": "#annotation"
},
{
"begin": "(?i)\\s*\\b([a-z0-9_]+)(?:[\\s\\t]*(as))?",
"beginCaptures": {
"1": {
"name": "variable.object.property.brs"
},
"2": {
"name": "keyword.control.as.brs"
}
},
"patterns": [
{
"include": "#type_expression"
}
],
"end": "\r?\n"
"include": "#interface_function"
},
{
"include": "#interface_field"
}
],
"end": "(?i)[\\s\\t]*(end[\\s\\t]*interface)",
Expand All @@ -754,6 +743,85 @@
}
}
},
"interface_field": {
"begin": "(?i)\\s*\\b([a-z0-9_]+)(?:[\\s\\t]*(as))?",
"beginCaptures": {
"1": {
"name": "variable.object.property.brs"
},
"2": {
"name": "keyword.control.as.brs"
}
},
"patterns": [
{
"include": "#type_expression"
},
{
"include": "#comment"
}
],
"end": "\r?\n"
},
"interface_function": {
"patterns": [
{
"include": "#interface_function_with_return_type"
},
{
"include": "#interface_function_plain"
}
]
},
"interface_function_plain": {
"match": "(?i:\\s*\\b(function|sub)[\\s\\t]+([a-z0-9_]+)(\\())(\\))[\\s\\t]",
"captures": {
"1": {
"name": "storage.type.function.brs"
},
"2": {
"name": "entity.name.function.member.brs"
},
"3": {
"name": "punctuation.definition.parameters.begin.brs"
},
"4": {
"name": "punctuation.definition.parameters.end.brs"
},
"5": {
"name": "keyword.control.as.brs"
}
}
},
"interface_function_with_return_type": {
"begin": "(?i:\\s*\\b(function|sub)[\\s\\t]+([a-z0-9_]+)(\\()).*?(\\))[\\s\\t]+(as)",
"beginCaptures": {
"1": {
"name": "storage.type.function.brs"
},
"2": {
"name": "entity.name.function.member.brs"
},
"3": {
"name": "punctuation.definition.parameters.begin.brs"
},
"4": {
"name": "punctuation.definition.parameters.end.brs"
},
"5": {
"name": "keyword.control.as.brs"
}
},
"patterns": [
{
"include": "#type_expression"
},
{
"include": "#comment"
}
],
"end": "\r?\n"
},
"enum_declaration": {
"name": "meta.enum.declaration.brs",
"begin": "(?i)\\b(enum)[ \\t]+([a-zA-Z0-9_]+)\\b",
Expand Down

0 comments on commit 788c623

Please sign in to comment.