diff --git a/crates/squawk_ide/src/classify.rs b/crates/squawk_ide/src/classify.rs index 75b5ef0b..c4230d5f 100644 --- a/crates/squawk_ide/src/classify.rs +++ b/crates/squawk_ide/src/classify.rs @@ -317,7 +317,8 @@ pub(crate) fn classify_name_ref(node: &SyntaxNode) -> Option { .and_then(|p| p.syntax().parent().and_then(ast::Path::cast)) && let Some(stmt_parent) = path.syntax().parent() && (ast::AlterPropertyGraph::can_cast(stmt_parent.kind()) - || ast::DropPropertyGraph::can_cast(stmt_parent.kind())) + || ast::DropPropertyGraph::can_cast(stmt_parent.kind()) + || ast::GraphTableFn::can_cast(stmt_parent.kind())) { return Some(NameRefClass::PropertyGraph); } diff --git a/crates/squawk_ide/src/goto_definition.rs b/crates/squawk_ide/src/goto_definition.rs index de449880..6d4cb422 100644 --- a/crates/squawk_ide/src/goto_definition.rs +++ b/crates/squawk_ide/src/goto_definition.rs @@ -9722,4 +9722,20 @@ alter property graph foo.ba$0r rename to baz; ╰╴ ─ 1. source "); } + + #[test] + fn goto_graph_table_fn() { + assert_snapshot!(goto(" +create property graph myshop vertex tables (t key (a) no properties); +select 1 from graph_table (myshop$0 + match (n is t) + columns (1 as x)); +"), @" + ╭▸ + 2 │ create property graph myshop vertex tables (t key (a) no properties); + │ ────── 2. destination + 3 │ select 1 from graph_table (myshop + ╰╴ ─ 1. source + "); + } } diff --git a/crates/squawk_ide/src/semantic_tokens.rs b/crates/squawk_ide/src/semantic_tokens.rs index bdf0af91..3256c341 100644 --- a/crates/squawk_ide/src/semantic_tokens.rs +++ b/crates/squawk_ide/src/semantic_tokens.rs @@ -173,6 +173,7 @@ pub enum SemanticTokenType { Type, Parameter, PositionalParam, + PropertyGraph, Table, Schema, } @@ -188,6 +189,7 @@ impl TryFrom for SemanticTokenType { LocationKind::Column => Ok(SemanticTokenType::Column), LocationKind::NamedArgParameter => Ok(SemanticTokenType::Parameter), LocationKind::Schema => Ok(SemanticTokenType::Schema), + LocationKind::PropertyGraph => Ok(SemanticTokenType::PropertyGraph), LocationKind::Sequence | LocationKind::Table | LocationKind::View => { Ok(SemanticTokenType::Table) } @@ -203,7 +205,6 @@ impl TryFrom for SemanticTokenType { | LocationKind::Index | LocationKind::Policy | LocationKind::PreparedStatement - | LocationKind::PropertyGraph | LocationKind::Role | LocationKind::Server | LocationKind::Tablespace @@ -820,6 +821,18 @@ select * from t; "#); } + #[test] + fn create_property_graph() { + assert_snapshot!(semantic_tokens( + " +create property graph foo + vertex tables (bar key (a) no properties); +", + ), @r#" + "foo" @ 23..26: PropertyGraph + "#); + } + #[test] fn select_target_schema_qualified() { assert_snapshot!(semantic_tokens( diff --git a/crates/squawk_server/src/lsp_utils.rs b/crates/squawk_server/src/lsp_utils.rs index e03a6ba2..20479b0b 100644 --- a/crates/squawk_server/src/lsp_utils.rs +++ b/crates/squawk_server/src/lsp_utils.rs @@ -320,7 +320,9 @@ fn to_token_type(ty: SemanticTokenType) -> lsp_types::SemanticTokenType { lsp_types::SemanticTokenType::PARAMETER } SemanticTokenType::Column => lsp_types::SemanticTokenType::VARIABLE, - SemanticTokenType::Table => lsp_types::SemanticTokenType::STRUCT, + SemanticTokenType::PropertyGraph | SemanticTokenType::Table => { + lsp_types::SemanticTokenType::STRUCT + } SemanticTokenType::Schema => lsp_types::SemanticTokenType::NAMESPACE, } } diff --git a/crates/squawk_wasm/src/lib.rs b/crates/squawk_wasm/src/lib.rs index bf03756d..c2b8b59d 100644 --- a/crates/squawk_wasm/src/lib.rs +++ b/crates/squawk_wasm/src/lib.rs @@ -41,7 +41,7 @@ fn semantic_token_type_name(ty: SemanticTokenType) -> &'static str { SemanticTokenType::Parameter | SemanticTokenType::PositionalParam => "parameter", SemanticTokenType::Schema => "namespace", SemanticTokenType::String => "string", - SemanticTokenType::Table => "struct", + SemanticTokenType::PropertyGraph | SemanticTokenType::Table => "struct", SemanticTokenType::Type => "type", } }