tree_sitter_stack_graphs_python/
lib.rs1use tree_sitter_stack_graphs::loader::LanguageConfiguration;
9use tree_sitter_stack_graphs::loader::LoadError;
10use tree_sitter_stack_graphs::CancellationFlag;
11
12pub const STACK_GRAPHS_TSG_PATH: &str = "src/stack-graphs.tsg";
14pub const STACK_GRAPHS_TSG_SOURCE: &str = include_str!("../src/stack-graphs.tsg");
16
17pub const STACK_GRAPHS_BUILTINS_CONFIG: &str = include_str!("../src/builtins.cfg");
19pub const STACK_GRAPHS_BUILTINS_PATH: &str = "src/builtins.py";
21pub const STACK_GRAPHS_BUILTINS_SOURCE: &str = include_str!("../src/builtins.py");
23
24pub fn language_configuration(cancellation_flag: &dyn CancellationFlag) -> LanguageConfiguration {
25 try_language_configuration(cancellation_flag).unwrap_or_else(|err| panic!("{}", err))
26}
27
28pub fn try_language_configuration(
29 cancellation_flag: &dyn CancellationFlag,
30) -> Result<LanguageConfiguration, LoadError> {
31 LanguageConfiguration::from_sources(
32 tree_sitter_python::LANGUAGE.into(),
33 Some(String::from("source.py")),
34 None,
35 vec![String::from("py")],
36 STACK_GRAPHS_TSG_PATH.into(),
37 STACK_GRAPHS_TSG_SOURCE,
38 Some((
39 STACK_GRAPHS_BUILTINS_PATH.into(),
40 STACK_GRAPHS_BUILTINS_SOURCE,
41 )),
42 Some(STACK_GRAPHS_BUILTINS_CONFIG),
43 cancellation_flag,
44 )
45}