55// Please see the LICENSE-APACHE or LICENSE-MIT files in this distribution for license details.
66// ------------------------------------------------------------------------------------------------
77
8- use stack_graphs:: graph:: StackGraph ;
98use tree_sitter_stack_graphs:: loader:: LanguageConfiguration ;
10- use tree_sitter_stack_graphs:: loader:: Loader ;
119use tree_sitter_stack_graphs:: CancellationFlag ;
12- use tree_sitter_stack_graphs:: StackGraphLanguage ;
13- use tree_sitter_stack_graphs:: Variables ;
1410
1511/// The stack graphs tsg source for this language
1612const STACK_GRAPHS_TSG_SOURCE : & str = include_str ! ( "../src/stack-graphs.tsg" ) ;
@@ -21,27 +17,15 @@ const STACK_GRAPHS_BUILTINS_CONFIG: &str = include_str!("../src/builtins.cfg");
2117const STACK_GRAPHS_BUILTINS_SOURCE : & str = include_str ! ( "../src/builtins.ts" ) ;
2218
2319pub fn language_configuration ( cancellation_flag : & dyn CancellationFlag ) -> LanguageConfiguration {
24- let language = tree_sitter_typescript:: language_typescript ( ) ;
25- let sgl = StackGraphLanguage :: from_str ( language, STACK_GRAPHS_TSG_SOURCE ) . unwrap ( ) ;
26- let mut builtins = StackGraph :: new ( ) ;
27- let file = builtins. add_file ( "<builtins>" ) . unwrap ( ) ;
28- let mut builtins_globals = Variables :: new ( ) ;
29- Loader :: load_globals_from_config_str ( STACK_GRAPHS_BUILTINS_CONFIG , & mut builtins_globals)
30- . unwrap ( ) ;
31- sgl. build_stack_graph_into (
32- & mut builtins,
33- file,
34- STACK_GRAPHS_BUILTINS_SOURCE ,
35- & builtins_globals,
20+ LanguageConfiguration :: from_tsg_str (
21+ tree_sitter_typescript:: language_typescript ( ) ,
22+ Some ( String :: from ( "source.ts" ) ) ,
23+ None ,
24+ vec ! [ String :: from( "ts" ) ] ,
25+ STACK_GRAPHS_TSG_SOURCE ,
26+ Some ( STACK_GRAPHS_BUILTINS_SOURCE ) ,
27+ Some ( STACK_GRAPHS_BUILTINS_CONFIG ) ,
3628 cancellation_flag,
3729 )
38- . unwrap ( ) ;
39- LanguageConfiguration {
40- language,
41- scope : Some ( String :: from ( "source.ts" ) ) ,
42- content_regex : None ,
43- file_types : vec ! [ String :: from( "ts" ) ] ,
44- sgl,
45- builtins,
46- }
30+ . unwrap ( )
4731}
0 commit comments