Skip to content
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

Bitbake operators in purple #35

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
2 changes: 1 addition & 1 deletion client/syntaxes/bitbake.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@
},
"bitbake-operator": {
"match": "(?<=:)(append|prepend|remove)",
"name": "keyword.other.bitbake-operator.bb"
"name": "keyword.control.bb"
},
"parenthesis-open": {
"match": "([\\w])*\\(",
Expand Down
6 changes: 3 additions & 3 deletions client/test/grammars/test-cases/bitbake-operator.bb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# SYNTAX TEST "source.bb" "bitbake-operators"

>KBRANCH:append
# ^^^^^^ source.bb keyword.other.bitbake-operator.bb
# ^^^^^^ source.bb keyword.control.bb

>KBRANCH:prepend
# ^^^^^^^ source.bb keyword.other.bitbake-operator.bb
# ^^^^^^^ source.bb keyword.control.bb

>KBRANCH:remove
# ^^^^^^ source.bb keyword.other.bitbake-operator.bb
# ^^^^^^ source.bb keyword.control.bb


>python do_foo:append() {
Expand Down
2 changes: 1 addition & 1 deletion client/test/grammars/test-cases/variables.bb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
>FOO:remove = "${FOOREMOVE}"
#^^^ source.bb variable.other.names.bb
# ^^^^^^^^^ source.bb string.quoted.double.bb variable.other.names.bb
# ^^^^^^ source.bb keyword.other.bitbake-operator.bb - variable.other.names.bb
# ^^^^^^ source.bb keyword.control.bb - variable.other.names.bb

>myfunc (var = '123', var2 = 123) {}
# ^^^ source.bb variable.other.names.bb
Expand Down
2 changes: 1 addition & 1 deletion server/src/__tests__/fixtures/semanticTokens.bb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FOO = 'FOO'

MYVAR:append = '${FOO}'
MYVAR:append:myoverride = '${FOO}'

do_build () {
echo 'do build'
Expand Down
6 changes: 3 additions & 3 deletions server/src/__tests__/semanticTokens.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ describe('Semantic tokens', () => {
},
{
line: 2,
startCharacter: 18,
startCharacter: 29,
length: 3,
tokenType: TOKEN_LEGEND.types.variable,
tokenModifiers: [TOKEN_LEGEND.modifiers.declaration]
},
{
line: 2,
startCharacter: 5,
length: 7,
startCharacter: 13,
length: 10,
tokenType: TOKEN_LEGEND.types.operator,
tokenModifiers: [TOKEN_LEGEND.modifiers.readonly]
},
Expand Down
16 changes: 5 additions & 11 deletions server/src/tree-sitter/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,14 @@ export function isVariableReference (n: SyntaxNode): boolean {
}
}

/**
* Check if the node is an override other than `append`, `prepend` or `remove`
*/
export function isOverride (n: SyntaxNode): boolean {
const parentTypes = [
'variable_assignment',
'function_definition',
'anonymous_python_function',
'python_function_definition'
]
const parentType = n?.parent?.type
switch (n.type) {
case 'override':
if (parentType !== undefined) {
return parentTypes.includes(parentType)
}
return false
case 'identifier':
return parentType === 'override' // As per the tree-sitter grammar, an identifier which has a parent of type override is an override other than `append`, `prepend` or `remove`
default:
return false
}
Expand Down
Loading