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

Chore: Update tree-sitter-bitbake #280

Merged
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
6 changes: 1 addition & 5 deletions server/src/semanticTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,7 @@ export function getBitBakeParsedTokens (uri: string): ParsedToken[] {
length: Math.max(node.endPosition.column - node.startPosition.column, 0)
}

if (
TreeSitterUtils.isVariableReference(node) &&
// bash variable expansions are handled by getBashParsedTokens
!analyzer.isInsideBashRegion(node)
) {
if (TreeSitterUtils.isVariableReference(node)) {
resultTokens.push({
...nodeRange,
tokenType: TOKEN_LEGEND.types.variable,
Expand Down
7 changes: 1 addition & 6 deletions server/src/tree-sitter/analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,7 @@ export default class Analyzer {

TreeSitterUtils.forEach(bitBakeTree.rootNode, (node) => {
// Bash variable expansions are handled separately in getSymbolsFromBashTree
const isInsideBashRegion = this.isInsideBashRegion(node)
const isNonEmptyVariableExpansion = (node.type === 'identifier' && node.parent?.type === 'variable_expansion' && !isInsideBashRegion)
const isNonEmptyVariableExpansion = (node.type === 'identifier' && node.parent?.type === 'variable_expansion')
const isPythonDatastoreVariable = this.isPythonDatastoreVariable(node)
const isPythonFunctionDefinition = node.type === 'python_function_definition'
// Note this does not detect python functions that are not called. Not sure how it could be done.
Expand Down Expand Up @@ -693,10 +692,6 @@ export default class Analyzer {
column: number
): boolean {
const n = this.bitBakeNodeAtPoint(uri, line, column)
if (n !== null && this.isInsideBashRegion(n)) {
// Bash variable expansions are handled with isBashVariableName
return false
}
// since @1.0.2 the tree-sitter gives empty variable expansion (e.g. `VAR = "${}""`) the type "variable_expansion". But the node type returned from bitBakeNodeAtPoint() at the position between "${" and "}" is of type "${" which is the result from descendantForPosition() (It returns the smallest node containing the given postion). In this case, the parent node has type "variable_expansion". Hence, we have n?.parent?.type === 'variable_expansion' below. The second expression after the || will be true if it encounters non-empty variable expansion syntax. e.g. `VAR = "${A}". Note that inline python with ${@} has type "inline_python"
return n?.parent?.type === 'variable_expansion' || (n?.type === 'identifier' && n?.parent?.type === 'variable_expansion')
}
Expand Down
2 changes: 1 addition & 1 deletion server/tree-sitter-bitbake.info
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"https://api.github.com/repos/idillon-sfl/tree-sitter-bitbake/git/commits/c69337c5c8f374613fb13f2dc8738e7827353084"
"https://api.github.com/repos/idillon-sfl/tree-sitter-bitbake/git/commits/821169a172bfe3c7125927ca151e299a1f43759b"
tree-sitter-cli "^0.22.6"