Skip to content

Commit

Permalink
Chore: Display bitbake operators in purple and other overrides remain…
Browse files Browse the repository at this point in the history
… as is
  • Loading branch information
WilsonZiweiWang committed Dec 22, 2023
1 parent e251c66 commit d117c28
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
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
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`, `preprend` 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`, `preprend` or `remove`
default:
return false
}
Expand Down

0 comments on commit d117c28

Please sign in to comment.