Skip to content

Commit a1754e0

Browse files
introduce new treesitter type
1 parent 01f0fb5 commit a1754e0

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

crates/pgt_completions/src/relevance/filtering.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ impl CompletionFilter<'_> {
163163
// only autocomplete left side of binary expression
164164
WrappingClause::Where => {
165165
ctx.before_cursor_matches_kind(&["keyword_and", "keyword_where"])
166-
|| (ctx.before_cursor_matches_kind(&["."])
166+
|| (ctx.before_cursor_matches_kind(&["field_qualifier"])
167167
&& ctx.matches_ancestor_history(&["field"]))
168168
}
169169

crates/pgt_treesitter/src/queries/select_columns.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ static TS_QUERY: LazyLock<tree_sitter::Query> = LazyLock::new(|| {
1010
(select_expression
1111
(term
1212
(field
13-
(object_reference)? @alias
14-
"."?
13+
(field_qualifier
14+
(object_reference) @alias
15+
"."
16+
)?
1517
(identifier) @column
1618
)
1719
)

crates/pgt_treesitter/src/queries/where_columns.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ static TS_QUERY: LazyLock<tree_sitter::Query> = LazyLock::new(|| {
1212
(binary_expression
1313
(binary_expression
1414
(field
15-
(object_reference)? @alias
16-
"."?
15+
(field_qualifier
16+
(object_reference) @alias
17+
"."
18+
)?
1719
(identifier) @column
1820
)
1921
)

crates/pgt_treesitter_grammar/grammar.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module.exports = grammar({
2121
],
2222

2323
conflicts: ($) => [
24+
[$.all_fields, $.field_qualifier],
2425
[$.object_reference, $._qualified_field],
2526
[$.object_reference],
2627
[$.between_expression, $.binary_expression],
@@ -2805,10 +2806,10 @@ module.exports = grammar({
28052806
field: ($) => field("name", $.identifier),
28062807

28072808
_qualified_field: ($) =>
2808-
seq(
2809-
optional(seq(optional_parenthesis($.object_reference), ".")),
2810-
field("name", $.identifier)
2811-
),
2809+
seq(optional($.field_qualifier), field("name", $.identifier)),
2810+
2811+
field_qualifier: ($) =>
2812+
seq(prec.left(optional_parenthesis($.object_reference)), "."),
28122813

28132814
implicit_cast: ($) => seq($._expression, "::", $.type),
28142815

0 commit comments

Comments
 (0)