4/11: feat(treesitter): add helper module with navigation utilities#657
Merged
juleswritescode merged 3 commits intostacked/pr629-3-benchmarksfrom Jan 25, 2026
Merged
Conversation
added 2 commits
January 24, 2026 13:52
…ase-community/postgres_lsp into stacked/pr629-4-helper-module
psteinroe
approved these changes
Jan 25, 2026
crates/pgls_treesitter/src/helper.rs
Outdated
| @@ -0,0 +1,120 @@ | |||
| use tree_sitter::{Node, Tree}; | |||
|
|
|||
| pub static SINGLE_TOKEN_RULES: &[&'static str] = &[ | |||
Collaborator
There was a problem hiding this comment.
like what is this list / how is it defined?
Collaborator
Author
There was a problem hiding this comment.
some treesitter nodes only ever have one child, such as literal:
program [0..12] 'select true;'
statement [0..11] 'select true'
select [0..11] 'select true'
keyword_select [0..6] 'select'
select_expression [7..11] 'true'
term [7..11] 'true'
literal [7..11] 'true'
keyword_true [7..11] 'true'
; [11..12] ';'
So we're basically saying, "these token rules are always completed".
Alternatively, we could mark all children with an @end tag; I might do that later:
literal: ($) =>
field("end", prec(
2,
choice(
$._integer,
$._decimal_number,
$._literal_string,
$._bit_string,
$._string_casting,
$.keyword_true,
$.keyword_false,
$.keyword_null
)
)),
a78e1e7
into
stacked/pr629-3-benchmarks
5 of 8 checks passed
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
goto_node_at_position,goto_previous_leaf,goto_closest_unfinished_parent_clauseprevious_sibling_completed,last_children_completedSINGLE_TOKEN_RULESconstantPart of stacked PRs for #629
This is PR 4/11 in the keyword completion feature stack.