tree_sitter_stack_graphs_java/
lib.rs

1use tree_sitter_stack_graphs::loader::LanguageConfiguration;
2use tree_sitter_stack_graphs::loader::LoadError;
3use tree_sitter_stack_graphs::CancellationFlag;
4
5/// The stacks graphs tsg path for this language.
6pub const STACK_GRAPHS_TSG_PATH: &str = "src/stack-graphs.tsg";
7/// The stack graphs tsg source for this language.
8pub const STACK_GRAPHS_TSG_SOURCE: &str = include_str!("../src/stack-graphs.tsg");
9
10/// The stack graphs builtins configuration for this language.
11pub const STACK_GRAPHS_BUILTINS_CONFIG: &str = include_str!("../src/builtins.cfg");
12/// The stack graphs builtins path for this language.
13pub const STACK_GRAPHS_BUILTINS_PATH: &str = "src/builtins.java";
14/// The stack graphs builtins source for this language.
15pub const STACK_GRAPHS_BUILTINS_SOURCE: &str = include_str!("../src/builtins.java");
16
17/// The name of the project name global variable
18pub const PROJECT_NAME_VAR: &str = "PROJECT_NAME";
19
20pub fn language_configuration(cancellation_flag: &dyn CancellationFlag) -> LanguageConfiguration {
21    try_language_configuration(cancellation_flag).unwrap_or_else(|err| panic!("{}", err))
22}
23
24pub fn try_language_configuration(
25    cancellation_flag: &dyn CancellationFlag,
26) -> Result<LanguageConfiguration, LoadError> {
27    LanguageConfiguration::from_sources(
28        tree_sitter_java::LANGUAGE.into(),
29        Some(String::from("source.java")),
30        None,
31        vec![String::from("java")],
32        STACK_GRAPHS_TSG_PATH.into(),
33        STACK_GRAPHS_TSG_SOURCE,
34        Some((
35            STACK_GRAPHS_BUILTINS_PATH.into(),
36            STACK_GRAPHS_BUILTINS_SOURCE,
37        )),
38        Some(STACK_GRAPHS_BUILTINS_CONFIG),
39        cancellation_flag,
40    )
41}