From f17e0cd72cedbfef8fe6a5bd82c543844ee689bd Mon Sep 17 00:00:00 2001 From: Caleb White Date: Wed, 21 Feb 2024 15:26:47 -0600 Subject: [PATCH 1/4] chore: bump cli version --- package.json | 2 +- php/src/grammar.json | 1 - php_only/src/grammar.json | 1 - queries/highlights.scm | 35 ++++++++++++++++++----------------- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 2d1f5f19..c04f810d 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "eslint-config-google": "^0.14.0", "node-gyp": "^10.0.1", "shelljs": "^0.8.5", - "tree-sitter-cli": "^0.20.8" + "tree-sitter-cli": "^0.21.0" }, "scripts": { "build": "npm run build-php && npm run build-php_only && node-gyp rebuild", diff --git a/php/src/grammar.json b/php/src/grammar.json index 28b3669d..111f81e0 100644 --- a/php/src/grammar.json +++ b/php/src/grammar.json @@ -9189,4 +9189,3 @@ "_literal" ] } - diff --git a/php_only/src/grammar.json b/php_only/src/grammar.json index 092873e2..41a423c2 100644 --- a/php_only/src/grammar.json +++ b/php_only/src/grammar.json @@ -9180,4 +9180,3 @@ "_literal" ] } - diff --git a/queries/highlights.scm b/queries/highlights.scm index cc352581..1915f5bf 100644 --- a/queries/highlights.scm +++ b/queries/highlights.scm @@ -1,6 +1,24 @@ (php_tag) @tag "?>" @tag + +; Variables + +(relative_scope) @variable.builtin + +(variable_name) @variable + +((name) @constant + (#match? @constant "^_?[A-Z][A-Z\\d_]+$")) +((name) @constant.builtin + (#match? @constant.builtin "^__[A-Z][A-Z\d_]+__$")) + +((name) @constructor + (#match? @constructor "^[A-Z]")) + +((name) @variable.builtin + (#eq? @variable.builtin "this")) + ; Types (primitive_type) @type.builtin @@ -38,23 +56,6 @@ (member_access_expression name: (name) @property) -; Variables - -(relative_scope) @variable.builtin - -((name) @constant - (#match? @constant "^_?[A-Z][A-Z\\d_]+$")) -((name) @constant.builtin - (#match? @constant.builtin "^__[A-Z][A-Z\d_]+__$")) - -((name) @constructor - (#match? @constructor "^[A-Z]")) - -((name) @variable.builtin - (#eq? @variable.builtin "this")) - -(variable_name) @variable - ; Basic tokens [ (string) From 261c5a320211d7dc2817f43cfda836f4e08cabce Mon Sep 17 00:00:00 2001 From: Caleb White Date: Wed, 21 Feb 2024 15:50:35 -0600 Subject: [PATCH 2/4] feat: add external-files key to tree-sitter config --- package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c04f810d..5b6d1fee 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,10 @@ "queries/injections.scm", "queries/injections-text.scm" ], - "tags": "queries/tags.scm" + "tags": "queries/tags.scm", + "external-files": [ + "common/scanner.h" + ] } ] } From 5dd836f0564836f8de5eb1f5646b520ea7f43042 Mon Sep 17 00:00:00 2001 From: Caleb White Date: Wed, 21 Feb 2024 16:12:22 -0600 Subject: [PATCH 3/4] test: clone examples with depth=1 to speed up test --- script/parse-examples | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/parse-examples b/script/parse-examples index 6c47a240..47ed4b34 100755 --- a/script/parse-examples +++ b/script/parse-examples @@ -12,14 +12,14 @@ function clone_repo { path=examples/$name if [ ! -d "$path" ]; then echo "Cloning $owner/$name" - git clone "https://github.com/$owner/$name" "$path" + git clone --depth 1 "https://github.com/$owner/$name" "$path" fi pushd "$path" >/dev/null actual_sha=$(git rev-parse HEAD) if [ "$actual_sha" != "$sha" ]; then echo "Updating $owner/$name to $sha" - git fetch + git fetch --depth 1 origin "$sha" git reset --hard "$sha" fi popd >/dev/null From f833f534221049c0adc3313102e8140604605711 Mon Sep 17 00:00:00 2001 From: Caleb White Date: Wed, 21 Feb 2024 16:20:09 -0600 Subject: [PATCH 4/4] fix: move 'this' query lower in the highlights --- queries/highlights.scm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/queries/highlights.scm b/queries/highlights.scm index 1915f5bf..99663358 100644 --- a/queries/highlights.scm +++ b/queries/highlights.scm @@ -16,9 +16,6 @@ ((name) @constructor (#match? @constructor "^[A-Z]")) -((name) @variable.builtin - (#eq? @variable.builtin "this")) - ; Types (primitive_type) @type.builtin @@ -71,6 +68,9 @@ (float) @number (comment) @comment +((name) @variable.builtin + (#eq? @variable.builtin "this")) + "$" @operator ; Keywords