Skip to content

Commit 2d37803

Browse files
quicksave
1 parent 299e469 commit 2d37803

File tree

4 files changed

+50
-57
lines changed

4 files changed

+50
-57
lines changed

crates/pgt_completions/src/context/grant_parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl GrantParser {
8686
{
8787
"grant" => {
8888
self.context.node_range = token.get_range();
89-
self.context.node_kind = "keyword_grant".into();
89+
self.context.node_kind = "grant_role".into();
9090
self.context.node_text = token.get_word();
9191
}
9292
"on" if !matches!(current.as_ref().map(|c| c.as_str()), Some("table")) => {
@@ -239,7 +239,7 @@ mod tests {
239239
schema_name: None,
240240
node_text: "REPLACED_TOKEN".into(),
241241
node_range: TextRange::new(TextSize::new(19), TextSize::new(33)),
242-
node_kind: "keyword_grant".into(),
242+
node_kind: "grant_role".into(),
243243
}
244244
);
245245
}

crates/pgt_completions/src/context/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ pub enum WrappingClause<'a> {
4141
SetStatement,
4242
AlterRole,
4343
DropRole,
44-
Grant,
4544
}
4645

4746
#[derive(PartialEq, Eq, Hash, Debug, Clone)]
@@ -233,7 +232,6 @@ impl<'a> CompletionContext<'a> {
233232
}
234233

235234
self.wrapping_clause_type = match grant_context.node_kind.as_str() {
236-
"keyword_grant" => Some(WrappingClause::Grant),
237235
"grant_role" => Some(WrappingClause::ToRoleAssignment),
238236
"grant_table" => Some(WrappingClause::From),
239237
_ => None,

crates/pgt_completions/src/providers/roles.rs

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -179,55 +179,55 @@ mod tests {
179179

180180
#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")]
181181
async fn works_in_grant_statements(pool: PgPool) {
182-
// assert_complete_results(
183-
// format!(
184-
// r#"grant select
185-
// on table public.users
186-
// to {}"#,
187-
// CURSOR_POS
188-
// )
189-
// .as_str(),
190-
// vec![
191-
// // recognizing already mentioned roles is not supported for now
192-
// CompletionAssertion::LabelAndKind("owner".into(), crate::CompletionItemKind::Role),
193-
// CompletionAssertion::LabelAndKind(
194-
// "test_login".into(),
195-
// crate::CompletionItemKind::Role,
196-
// ),
197-
// CompletionAssertion::LabelAndKind(
198-
// "test_nologin".into(),
199-
// crate::CompletionItemKind::Role,
200-
// ),
201-
// ],
202-
// None,
203-
// &pool,
204-
// )
205-
// .await;
182+
assert_complete_results(
183+
format!(
184+
r#"grant select
185+
on table public.users
186+
to {}"#,
187+
CURSOR_POS
188+
)
189+
.as_str(),
190+
vec![
191+
// recognizing already mentioned roles is not supported for now
192+
CompletionAssertion::LabelAndKind("owner".into(), crate::CompletionItemKind::Role),
193+
CompletionAssertion::LabelAndKind(
194+
"test_login".into(),
195+
crate::CompletionItemKind::Role,
196+
),
197+
CompletionAssertion::LabelAndKind(
198+
"test_nologin".into(),
199+
crate::CompletionItemKind::Role,
200+
),
201+
],
202+
None,
203+
&pool,
204+
)
205+
.await;
206206

207-
// assert_complete_results(
208-
// format!(
209-
// r#"grant select
210-
// on table public.users
211-
// to owner, {}"#,
212-
// CURSOR_POS
213-
// )
214-
// .as_str(),
215-
// vec![
216-
// // recognizing already mentioned roles is not supported for now
217-
// CompletionAssertion::LabelAndKind("owner".into(), crate::CompletionItemKind::Role),
218-
// CompletionAssertion::LabelAndKind(
219-
// "test_login".into(),
220-
// crate::CompletionItemKind::Role,
221-
// ),
222-
// CompletionAssertion::LabelAndKind(
223-
// "test_nologin".into(),
224-
// crate::CompletionItemKind::Role,
225-
// ),
226-
// ],
227-
// None,
228-
// &pool,
229-
// )
230-
// .await;
207+
assert_complete_results(
208+
format!(
209+
r#"grant select
210+
on table public.users
211+
to owner, {}"#,
212+
CURSOR_POS
213+
)
214+
.as_str(),
215+
vec![
216+
// recognizing already mentioned roles is not supported for now
217+
CompletionAssertion::LabelAndKind("owner".into(), crate::CompletionItemKind::Role),
218+
CompletionAssertion::LabelAndKind(
219+
"test_login".into(),
220+
crate::CompletionItemKind::Role,
221+
),
222+
CompletionAssertion::LabelAndKind(
223+
"test_nologin".into(),
224+
crate::CompletionItemKind::Role,
225+
),
226+
],
227+
None,
228+
&pool,
229+
)
230+
.await;
231231

232232
assert_complete_results(
233233
format!(r#"grant {} to owner"#, CURSOR_POS).as_str(),

crates/pgt_completions/src/relevance/filtering.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,6 @@ impl CompletionFilter<'_> {
179179
| WrappingClause::AlterRole
180180
| WrappingClause::ToRoleAssignment => true,
181181

182-
WrappingClause::Grant => ctx
183-
.node_under_cursor
184-
.as_ref()
185-
.is_some_and(|n| n.kind() == "keyword_grant"),
186-
187182
WrappingClause::SetStatement => ctx
188183
.before_cursor_matches_kind(&["keyword_role", "keyword_authorization"]),
189184

0 commit comments

Comments
 (0)