Skip to content

Commit a574584

Browse files
authored
ide: graph_table goto def start (#1077)
1 parent 38ee75b commit a574584

5 files changed

Lines changed: 36 additions & 4 deletions

File tree

crates/squawk_ide/src/classify.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@ pub(crate) fn classify_name_ref(node: &SyntaxNode) -> Option<NameRefClass> {
317317
.and_then(|p| p.syntax().parent().and_then(ast::Path::cast))
318318
&& let Some(stmt_parent) = path.syntax().parent()
319319
&& (ast::AlterPropertyGraph::can_cast(stmt_parent.kind())
320-
|| ast::DropPropertyGraph::can_cast(stmt_parent.kind()))
320+
|| ast::DropPropertyGraph::can_cast(stmt_parent.kind())
321+
|| ast::GraphTableFn::can_cast(stmt_parent.kind()))
321322
{
322323
return Some(NameRefClass::PropertyGraph);
323324
}

crates/squawk_ide/src/goto_definition.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9722,4 +9722,20 @@ alter property graph foo.ba$0r rename to baz;
97229722
╰╴ ─ 1. source
97239723
");
97249724
}
9725+
9726+
#[test]
9727+
fn goto_graph_table_fn() {
9728+
assert_snapshot!(goto("
9729+
create property graph myshop vertex tables (t key (a) no properties);
9730+
select 1 from graph_table (myshop$0
9731+
match (n is t)
9732+
columns (1 as x));
9733+
"), @"
9734+
╭▸
9735+
2 │ create property graph myshop vertex tables (t key (a) no properties);
9736+
│ ────── 2. destination
9737+
3 │ select 1 from graph_table (myshop
9738+
╰╴ ─ 1. source
9739+
");
9740+
}
97259741
}

crates/squawk_ide/src/semantic_tokens.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ pub enum SemanticTokenType {
173173
Type,
174174
Parameter,
175175
PositionalParam,
176+
PropertyGraph,
176177
Table,
177178
Schema,
178179
}
@@ -188,6 +189,7 @@ impl TryFrom<LocationKind> for SemanticTokenType {
188189
LocationKind::Column => Ok(SemanticTokenType::Column),
189190
LocationKind::NamedArgParameter => Ok(SemanticTokenType::Parameter),
190191
LocationKind::Schema => Ok(SemanticTokenType::Schema),
192+
LocationKind::PropertyGraph => Ok(SemanticTokenType::PropertyGraph),
191193
LocationKind::Sequence | LocationKind::Table | LocationKind::View => {
192194
Ok(SemanticTokenType::Table)
193195
}
@@ -203,7 +205,6 @@ impl TryFrom<LocationKind> for SemanticTokenType {
203205
| LocationKind::Index
204206
| LocationKind::Policy
205207
| LocationKind::PreparedStatement
206-
| LocationKind::PropertyGraph
207208
| LocationKind::Role
208209
| LocationKind::Server
209210
| LocationKind::Tablespace
@@ -820,6 +821,18 @@ select * from t;
820821
"#);
821822
}
822823

824+
#[test]
825+
fn create_property_graph() {
826+
assert_snapshot!(semantic_tokens(
827+
"
828+
create property graph foo
829+
vertex tables (bar key (a) no properties);
830+
",
831+
), @r#"
832+
"foo" @ 23..26: PropertyGraph
833+
"#);
834+
}
835+
823836
#[test]
824837
fn select_target_schema_qualified() {
825838
assert_snapshot!(semantic_tokens(

crates/squawk_server/src/lsp_utils.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,9 @@ fn to_token_type(ty: SemanticTokenType) -> lsp_types::SemanticTokenType {
320320
lsp_types::SemanticTokenType::PARAMETER
321321
}
322322
SemanticTokenType::Column => lsp_types::SemanticTokenType::VARIABLE,
323-
SemanticTokenType::Table => lsp_types::SemanticTokenType::STRUCT,
323+
SemanticTokenType::PropertyGraph | SemanticTokenType::Table => {
324+
lsp_types::SemanticTokenType::STRUCT
325+
}
324326
SemanticTokenType::Schema => lsp_types::SemanticTokenType::NAMESPACE,
325327
}
326328
}

crates/squawk_wasm/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fn semantic_token_type_name(ty: SemanticTokenType) -> &'static str {
4141
SemanticTokenType::Parameter | SemanticTokenType::PositionalParam => "parameter",
4242
SemanticTokenType::Schema => "namespace",
4343
SemanticTokenType::String => "string",
44-
SemanticTokenType::Table => "struct",
44+
SemanticTokenType::PropertyGraph | SemanticTokenType::Table => "struct",
4545
SemanticTokenType::Type => "type",
4646
}
4747
}

0 commit comments

Comments
 (0)