Skip to content

Commit

Permalink
feat: go package identifier (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
seren5240 authored Mar 12, 2024
1 parent 45cc15a commit 3865d22
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
44 changes: 44 additions & 0 deletions crates/core/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
3 changes: 2 additions & 1 deletion crates/language/src/csharp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<Vec<Field>>> = OnceLock::new();
static LANGUAGE: OnceLock<TSLanguage> = OnceLock::new();

Expand Down
8 changes: 7 additions & 1 deletion crates/language/src/go.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Field>] {
Expand Down
3 changes: 2 additions & 1 deletion crates/language/src/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<Vec<Field>>> = OnceLock::new();
static LANGUAGE: OnceLock<TSLanguage> = OnceLock::new();

Expand Down

0 comments on commit 3865d22

Please sign in to comment.