@@ -19,7 +19,10 @@ pub mod util;
1919/// The stacks graphs tsg path for this language.
2020pub const STACK_GRAPHS_TSG_PATH : & str = "src/stack-graphs.tsg" ;
2121/// The stack graphs tsg source for this language
22- pub const STACK_GRAPHS_TSG_SOURCE : & str = include_str ! ( "../src/stack-graphs.tsg" ) ;
22+ pub const STACK_GRAPHS_TSG_TS_SOURCE : & str =
23+ include_str ! ( concat!( env!( "OUT_DIR" ) , "/stack-graphs-typescript.tsg" ) ) ;
24+ pub const STACK_GRAPHS_TSG_TSX_SOURCE : & str =
25+ include_str ! ( concat!( env!( "OUT_DIR" ) , "/stack-graphs-tsx.tsg" ) ) ;
2326
2427/// The stack graphs builtins configuration for this language
2528pub const STACK_GRAPHS_BUILTINS_CONFIG : & str = include_str ! ( "../src/builtins.cfg" ) ;
@@ -33,11 +36,13 @@ pub const FILE_PATH_VAR: &str = "FILE_PATH";
3336/// The name of the project name global variable
3437pub const PROJECT_NAME_VAR : & str = "PROJECT_NAME" ;
3538
36- pub fn language_configuration ( cancellation_flag : & dyn CancellationFlag ) -> LanguageConfiguration {
37- try_language_configuration ( cancellation_flag) . unwrap_or_else ( |err| panic ! ( "{}" , err) )
39+ pub fn language_configuration_typescript (
40+ cancellation_flag : & dyn CancellationFlag ,
41+ ) -> LanguageConfiguration {
42+ try_language_configuration_typescript ( cancellation_flag) . unwrap_or_else ( |err| panic ! ( "{}" , err) )
3843}
3944
40- pub fn try_language_configuration (
45+ pub fn try_language_configuration_typescript (
4146 cancellation_flag : & dyn CancellationFlag ,
4247) -> Result < LanguageConfiguration , LoadError > {
4348 let mut lc = LanguageConfiguration :: from_sources (
@@ -46,7 +51,37 @@ pub fn try_language_configuration(
4651 None ,
4752 vec ! [ String :: from( "ts" ) ] ,
4853 STACK_GRAPHS_TSG_PATH . into ( ) ,
49- STACK_GRAPHS_TSG_SOURCE ,
54+ STACK_GRAPHS_TSG_TS_SOURCE ,
55+ Some ( (
56+ STACK_GRAPHS_BUILTINS_PATH . into ( ) ,
57+ STACK_GRAPHS_BUILTINS_SOURCE ,
58+ ) ) ,
59+ Some ( STACK_GRAPHS_BUILTINS_CONFIG ) ,
60+ cancellation_flag,
61+ ) ?;
62+ lc. special_files
63+ . add ( "tsconfig.json" . to_string ( ) , TsConfigAnalyzer { } )
64+ . add ( "package.json" . to_string ( ) , NpmPackageAnalyzer { } ) ;
65+ lc. no_similar_paths_in_file = true ;
66+ Ok ( lc)
67+ }
68+
69+ pub fn language_configuration_tsx (
70+ cancellation_flag : & dyn CancellationFlag ,
71+ ) -> LanguageConfiguration {
72+ try_language_configuration_tsx ( cancellation_flag) . unwrap_or_else ( |err| panic ! ( "{}" , err) )
73+ }
74+
75+ pub fn try_language_configuration_tsx (
76+ cancellation_flag : & dyn CancellationFlag ,
77+ ) -> Result < LanguageConfiguration , LoadError > {
78+ let mut lc = LanguageConfiguration :: from_sources (
79+ tree_sitter_typescript:: language_tsx ( ) ,
80+ Some ( String :: from ( "source.tsx" ) ) ,
81+ None ,
82+ vec ! [ String :: from( "tsx" ) ] ,
83+ STACK_GRAPHS_TSG_PATH . into ( ) ,
84+ STACK_GRAPHS_TSG_TSX_SOURCE ,
5085 Some ( (
5186 STACK_GRAPHS_BUILTINS_PATH . into ( ) ,
5287 STACK_GRAPHS_BUILTINS_SOURCE ,
0 commit comments