diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b4d34eba4..7d832c80d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -81,8 +81,8 @@ importers: specifier: 1.0.11 version: 1.0.11 web-tree-sitter: - specifier: 0.20.8 - version: 0.20.8 + specifier: 0.22.5 + version: 0.22.5 zod: specifier: 3.22.4 version: 3.22.4 @@ -3325,8 +3325,8 @@ packages: makeerror: 1.0.12 dev: true - /web-tree-sitter@0.20.8: - resolution: {integrity: sha512-weOVgZ3aAARgdnb220GqYuh7+rZU0Ka9k9yfKtGAzEYMa6GgiCzW9JjQRJyCJakvibQW+dfjJdihjInKuuCAUQ==} + /web-tree-sitter@0.22.5: + resolution: {integrity: sha512-rGX2jRXjcGOhf35zWyO0i/+Wjz4/KVUYN9Oh3AhDsZ0fGOgTIkw/bMhqwvc8L7HgMK8rqDq9RcROWc7lnsnhWg==} dev: false /webidl-conversions@3.0.1: diff --git a/scripts/upgrade-tree-sitter.sh b/scripts/upgrade-tree-sitter.sh index 5f5b29403..588afd49d 100755 --- a/scripts/upgrade-tree-sitter.sh +++ b/scripts/upgrade-tree-sitter.sh @@ -5,7 +5,7 @@ set -euox pipefail cd server pnpm add web-tree-sitter pnpm add --save-dev tree-sitter-cli https://github.com/tree-sitter/tree-sitter-bash -npx tree-sitter build-wasm node_modules/tree-sitter-bash +npx tree-sitter build --wasm node_modules/tree-sitter-bash curl 'https://api.github.com/repos/tree-sitter/tree-sitter-bash/commits/master' | jq .commit.url > parser.info echo "tree-sitter-cli $(cat package.json | jq '.devDependencies["tree-sitter-cli"]')" >> parser.info diff --git a/server/package.json b/server/package.json index b8f5d37ae..b029a8b9d 100644 --- a/server/package.json +++ b/server/package.json @@ -23,7 +23,7 @@ "turndown": "7.1.3", "vscode-languageserver": "8.0.2", "vscode-languageserver-textdocument": "1.0.11", - "web-tree-sitter": "0.20.8", + "web-tree-sitter": "0.22.5", "zod": "3.22.4" }, "scripts": { diff --git a/server/parser.info b/server/parser.info index 80e5b788f..80794bf24 100644 --- a/server/parser.info +++ b/server/parser.info @@ -1,2 +1,2 @@ -"https://api.github.com/repos/tree-sitter/tree-sitter-bash/git/commits/4488aa41406547e478636a4fcfd24f5bbc3f2f74" -tree-sitter-cli "0.20.7" +"https://api.github.com/repos/tree-sitter/tree-sitter-bash/git/commits/f8fb3274f72a30896075585b32b0c54cad65c086" +tree-sitter-cli "0.22.5" diff --git a/server/src/__tests__/server.test.ts b/server/src/__tests__/server.test.ts index e6b88d66c..37ee108ed 100644 --- a/server/src/__tests__/server.test.ts +++ b/server/src/__tests__/server.test.ts @@ -1431,7 +1431,6 @@ describe('server', () => { ['variable in let expression', 110, 4], ['variable in binary expression', 111, 9], ['variable in postfix expression', 111, 17], - ['variable in arithmetic expansion', 112, 14], ])('returns null for non-renamable symbol: %s', async (_, line, character) => { expect(await getPrepareRenameResult(line, character)).toBeNull() }) @@ -1741,9 +1740,9 @@ describe('server', () => { describe('Edge or not covered cases', () => { it('only includes variables typed as variable_name', async () => { const iRanges = await getFirstChangeRanges(getRenameRequestResult(106, 4)) - // This should be 6 if all instances within let and arithmetic + // This should be 6 if all instances within let, postfix, and binary // expressions are included. - expect(iRanges.length).toBe(2) + expect(iRanges.length).toBe(3) const lineRanges = await getFirstChangeRanges(getRenameRequestResult(118, 10)) // This should be 2 if the declaration of `line` is included. diff --git a/server/src/analyser.ts b/server/src/analyser.ts index 3a035f373..3d0115997 100644 --- a/server/src/analyser.ts +++ b/server/src/analyser.ts @@ -128,7 +128,7 @@ export default class Analyzer { }) } - if (tree.rootNode.hasError()) { + if (tree.rootNode.hasError) { logger.warn(`Error while parsing ${uri}: syntax error`) } diff --git a/server/src/util/sourcing.ts b/server/src/util/sourcing.ts index dbfdcae78..d378c7c20 100644 --- a/server/src/util/sourcing.ts +++ b/server/src/util/sourcing.ts @@ -109,7 +109,11 @@ function getSourcedPathInfoFromNode({ } if (argumentNode.type === 'string' || argumentNode.type === 'raw_string') { - if (argumentNode.namedChildren.length === 0) { + const children = argumentNode.namedChildren + if ( + children.length === 0 || + (children.length === 1 && children[0].type === 'string_content') + ) { return { sourcedPath: argumentNode.text.slice(1, -1), } diff --git a/server/tree-sitter-bash.wasm b/server/tree-sitter-bash.wasm index abeaa1f8d..40f6a564b 100755 Binary files a/server/tree-sitter-bash.wasm and b/server/tree-sitter-bash.wasm differ diff --git a/testing/fixtures/renaming.sh b/testing/fixtures/renaming.sh index ca0f0c1f9..addc5ca9c 100644 --- a/testing/fixtures/renaming.sh +++ b/testing/fixtures/renaming.sh @@ -121,13 +121,13 @@ done < somefile.txt # Complex nesting affects self-assignment handling -1() { +f1() { local var="var" - 2() ( + f2() ( var=$var - 3() { + f3() { declare var="$var" } )