Skip to content

Commit 22e971a

Browse files
unused
1 parent 172eaa0 commit 22e971a

File tree

2 files changed

+14
-78
lines changed

2 files changed

+14
-78
lines changed

crates/pgt_completions/src/relevance/filtering.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use pgt_schema_cache::ProcKind;
2-
use pgt_treesitter::context::{TreesitterContext, WrappingClause, WrappingNode};
2+
use pgt_treesitter::{
3+
MentionedColumn,
4+
context::{TreesitterContext, WrappingClause, WrappingNode},
5+
};
36

47
use super::CompletionRelevanceData;
58

@@ -101,6 +104,13 @@ impl CompletionFilter<'_> {
101104
&& !ctx.matches_ancestor_history(&["insert_values", "field"])
102105
&& !ctx.node_under_cursor_is_within_field_name("binary_expr_right")
103106
}
107+
"mentioned_column_identifier" => match self.data {
108+
CompletionRelevanceData::Column(column) => ctx
109+
// todo(juleswritescode): collect mentioned columns from more clauses
110+
.get_mentioned_columns(&None)
111+
.is_some_and(|cols| cols.iter().any(|c| c.column == column.name)),
112+
_ => false,
113+
},
104114
_ => false,
105115
};
106116

crates/pgt_treesitter_grammar/grammar.js

Lines changed: 3 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,6 @@ module.exports = grammar({
979979
$.table_partition,
980980
$.stored_as,
981981
$.storage_location,
982-
$.table_sort,
983982
$.row_format,
984983
seq($.keyword_tblproperties, paren_list($.table_option, true)),
985984
seq($.keyword_without, $.keyword_oids),
@@ -2551,10 +2550,6 @@ module.exports = grammar({
25512550
)
25522551
),
25532552

2554-
// todo(@juleswritescode): does this exist in postgresql?
2555-
table_sort: ($) =>
2556-
seq($.keyword_sort, $.keyword_by, paren_list($.any_identifier, true)),
2557-
25582553
table_partition: ($) =>
25592554
seq(
25602555
choice(
@@ -2627,12 +2622,7 @@ module.exports = grammar({
26272622
),
26282623

26292624
column_definitions: ($) =>
2630-
seq(
2631-
"(",
2632-
comma_list($.column_definition, true),
2633-
optional($.constraints),
2634-
")"
2635-
),
2625+
seq("(", comma_list($.column_definition, true), ")"),
26362626

26372627
column_definition: ($) =>
26382628
seq(
@@ -2663,8 +2653,7 @@ module.exports = grammar({
26632653
seq(
26642654
$.keyword_set,
26652655
choice($.keyword_null, $.keyword_default),
2666-
// todo(@juleswritescode): are these columns?
2667-
optional(paren_list($.any_identifier, true))
2656+
optional(paren_list($.mentioned_column_identifier, true))
26682657
)
26692658
)
26702659
)
@@ -2708,16 +2697,6 @@ module.exports = grammar({
27082697
alias($.implicit_cast, $.cast)
27092698
),
27102699

2711-
constraints: ($) => seq(",", $.constraint, repeat(seq(",", $.constraint))),
2712-
2713-
constraint: ($) =>
2714-
choice(
2715-
$._constraint_literal,
2716-
$._key_constraint,
2717-
$._primary_key_constraint,
2718-
$._check_constraint
2719-
),
2720-
27212700
_constraint_literal: ($) =>
27222701
seq(
27232702
$.keyword_constraint,
@@ -2727,59 +2706,6 @@ module.exports = grammar({
27272706

27282707
_primary_key_constraint: ($) => seq($._primary_key, $.ordered_columns),
27292708

2730-
_key_constraint: ($) =>
2731-
seq(
2732-
choice(
2733-
seq(
2734-
$.keyword_unique,
2735-
optional(
2736-
choice(
2737-
$.keyword_index,
2738-
$.keyword_key,
2739-
seq(
2740-
$.keyword_nulls,
2741-
optional($.keyword_not),
2742-
$.keyword_distinct
2743-
)
2744-
)
2745-
)
2746-
),
2747-
seq(
2748-
optional($.keyword_foreign),
2749-
$.keyword_key,
2750-
optional($._if_not_exists)
2751-
),
2752-
$.keyword_index
2753-
),
2754-
optional(field("name", $.any_identifier)),
2755-
$.ordered_columns,
2756-
optional(
2757-
seq(
2758-
$.keyword_references,
2759-
$.object_reference,
2760-
// todo(@juleswritescode): are these columns?
2761-
paren_list($.any_identifier, true),
2762-
repeat(
2763-
seq(
2764-
$.keyword_on,
2765-
choice($.keyword_delete, $.keyword_update),
2766-
choice(
2767-
seq($.keyword_no, $.keyword_action),
2768-
$.keyword_restrict,
2769-
$.keyword_cascade,
2770-
seq(
2771-
$.keyword_set,
2772-
choice($.keyword_null, $.keyword_default),
2773-
// todo(@juleswritescode): are these columns?
2774-
optional(paren_list($.any_identifier, true))
2775-
)
2776-
)
2777-
)
2778-
)
2779-
)
2780-
)
2781-
),
2782-
27832709
ordered_columns: ($) => paren_list(alias($.ordered_column, $.column), true),
27842710

27852711
ordered_column: ($) => seq(field("name", $._column), optional($.direction)),
@@ -3042,7 +2968,6 @@ module.exports = grammar({
30422968
seq(
30432969
$.keyword_as,
30442970
field("alias", $.any_identifier),
3045-
// todo(@juleswritescode): are these columns?
30462971
paren_list($.any_identifier, false)
30472972
)
30482973
)
@@ -3517,6 +3442,7 @@ module.exports = grammar({
35173442

35183443
any_identifier: ($) => $._any_identifier,
35193444
column_identifier: ($) => $._any_identifier,
3445+
mentioned_column_identifier: ($) => $._any_identifier,
35203446

35213447
_any_identifier: ($) =>
35223448
choice(

0 commit comments

Comments
 (0)