Tree-sitter queries: highlights, locals, tags#52
Merged
Conversation
Author the three shared query files against the frozen grammar node set (D3) and register them with the grammar package: - highlights.scm: keywords, Create types, command heads, member fields, resource/variable names, literals, labels, operators, punctuation. - locals.scm: a single file scope; Create / function / parameter / For-loop definitions and identifier references, for go-to-definition and find-references. - tags.scm: resource and GmatFunction definitions plus command and output-binding-call references, for the symbol outline and navigation. - tree-sitter.json / package.json: list locals alongside highlights (tags is auto-discovered); all three pack with the npm grammar. Add tests/test_queries.py: every query loads against the vendored compiled grammar, highlight captures land on the expected nodes, resource definition/reference resolution works on a fixture, and tags expose the resource and command symbols.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tree-sitter-gmat/queries/, against the frozen grammar node taxonomy (D3):Createtypes, command heads (@function), dotted member fields (@property), resource/variable names, numbers/strings/comments, command labels, operators, and punctuation. Patterns are ordered specific-first so a host resolving overlaps by first match gives the specific captures precedence over the catch-all.Createnames, GmatFunction names + parameters, andForvariables; an(identifier) @local.referencecatch-all. Powers go-to-definition / find-references.@definition.classfor resources,@definition.functionfor GmatFunction headers, and@reference.callfor mission commands and output-binding function calls (bare, dotted, and parenthesised shapes). Powers the document-symbol outline and code navigation.localsintree-sitter.jsonandpackage.jsonalongside the existinghighlights(tags is auto-discovered by convention); all three.scmfiles pack with the npm grammar (verified vianpm pack --dry-run).tests/test_queries.pyvalidating the definition of done.Note on tag kinds: resources are tagged
@definition.classas the closest standard kind for a named, typed object — a downstream LSP can remap to whateverSymbolKindit prefers.Test plan
locals.scmresolves a resource's definition to itsCreateand each use back to it (go-to-definition + find-references on a fixture).tags.scmexposes resource, function, command, and call symbols.ruff check,ruff format --check, andmypy(strict, tests included) clean.queries/*.scm.Closes #21