From 3865d22375a67c0b749ede643b32fd602cba29a6 Mon Sep 17 00:00:00 2001 From: Seren Kwok <86184664+seren5240@users.noreply.github.com> Date: Tue, 12 Mar 2024 14:52:42 +0000 Subject: [PATCH] feat: go package identifier (#9) --- crates/core/src/test.rs | 44 +++++++++++++++++++++++++++++++++++ crates/language/src/csharp.rs | 3 ++- crates/language/src/go.rs | 8 ++++++- crates/language/src/python.rs | 3 ++- 4 files changed, 55 insertions(+), 3 deletions(-) diff --git a/crates/core/src/test.rs b/crates/core/src/test.rs index da177ed8e..e31273d33 100644 --- a/crates/core/src/test.rs +++ b/crates/core/src/test.rs @@ -12583,3 +12583,47 @@ fn go_field_identifier() { }) .unwrap(); } + +#[test] +fn go_package_identifier() { + run_test_match(TestArg { + pattern: r#" + |language go + | + |`mypackage` + |"# + .trim_margin() + .unwrap(), + source: r#" + |func ZoneLockdown(api *mypackage.API) (resp interface{}, err error) { + | resp, err = api.Call() + | return + |} + |"# + .trim_margin() + .unwrap(), + }) + .unwrap(); +} + +#[test] +fn go_package_type() { + run_test_match(TestArg { + pattern: r#" + |language go + | + |`API` + |"# + .trim_margin() + .unwrap(), + source: r#" + |func ZoneLockdown(api *mypackage.API) (resp interface{}, err error) { + | resp, err = api.Call() + | return + |} + |"# + .trim_margin() + .unwrap(), + }) + .unwrap(); +} diff --git a/crates/language/src/csharp.rs b/crates/language/src/csharp.rs index a6cac47b9..992cfb14a 100644 --- a/crates/language/src/csharp.rs +++ b/crates/language/src/csharp.rs @@ -2,7 +2,8 @@ use std::sync::OnceLock; use crate::language::{fields_for_nodes, Field, Language, SortId, TSLanguage}; -static NODE_TYPES_STRING: &str = include_str!("../../../resources/node-types/csharp-node-types.json"); +static NODE_TYPES_STRING: &str = + include_str!("../../../resources/node-types/csharp-node-types.json"); static NODE_TYPES: OnceLock>> = OnceLock::new(); static LANGUAGE: OnceLock = OnceLock::new(); diff --git a/crates/language/src/go.rs b/crates/language/src/go.rs index 264054f1f..dee44ea09 100644 --- a/crates/language/src/go.rs +++ b/crates/language/src/go.rs @@ -49,7 +49,13 @@ impl Language for Go { "Go" } fn snippet_context_strings(&self) -> &[(&'static str, &'static str)] { - &[("", ""), ("", ";"), ("GO_OBJECT.", ";")] + &[ + ("", ""), + ("", ";"), + ("GO_OBJECT.", ";"), + ("func GRIT_FUNC(GRIT_ARG *", ".GRIT_TYPE) {}"), + ("func GRIT_FUNC(GRIT_ARG *GRIT_PACKAGE.", ") {}"), + ] } fn node_types(&self) -> &[Vec] { diff --git a/crates/language/src/python.rs b/crates/language/src/python.rs index 9619d35c1..ccaef0acd 100644 --- a/crates/language/src/python.rs +++ b/crates/language/src/python.rs @@ -2,7 +2,8 @@ use std::sync::OnceLock; use crate::language::{fields_for_nodes, Field, Language, SortId, TSLanguage}; -static NODE_TYPES_STRING: &str = include_str!("../../../resources/node-types/python-node-types.json"); +static NODE_TYPES_STRING: &str = + include_str!("../../../resources/node-types/python-node-types.json"); static NODE_TYPES: OnceLock>> = OnceLock::new(); static LANGUAGE: OnceLock = OnceLock::new();