@@ -11,11 +11,11 @@ use tower_lsp_server::{
1111} ;
1212
1313use oxc_allocator:: { Allocator , AllocatorPool } ;
14- use oxc_linter:: RuntimeFileSystem ;
1514use oxc_linter:: {
1615 LINTABLE_EXTENSIONS , LintService , LintServiceOptions , Linter , MessageWithPosition ,
17- loader:: Loader , read_to_string ,
16+ loader:: Loader , read_to_arena_str ,
1817} ;
18+ use oxc_linter:: { RuntimeFileSystem , read_to_string} ;
1919
2020use super :: error_with_position:: {
2121 DiagnosticReport , PossibleFixContent , message_with_position_to_lsp_diagnostic_report,
@@ -45,12 +45,17 @@ impl IsolatedLintHandlerFileSystem {
4545}
4646
4747impl RuntimeFileSystem for IsolatedLintHandlerFileSystem {
48- fn read_to_string ( & self , path : & Path ) -> Result < String , std:: io:: Error > {
48+ fn read_to_arena_str < ' a > (
49+ & self ,
50+ path : & Path ,
51+ allocator : & ' a Allocator ,
52+ ) -> Result < & ' a str , std:: io:: Error > {
4953 if path == self . path_to_lint {
50- return Ok ( self . source_text . clone ( ) ) ;
54+ // TODO: i think we can avoid allocating here.
55+ return Ok ( allocator. alloc_str ( & self . source_text ) ) ;
5156 }
5257
53- read_to_string ( path)
58+ read_to_arena_str ( path, allocator )
5459 }
5560
5661 fn write_file ( & self , _path : & Path , _content : String ) -> Result < ( ) , std:: io:: Error > {
@@ -129,6 +134,7 @@ impl IsolatedLintHandler {
129134 debug ! ( "extension not supported yet." ) ;
130135 return None ;
131136 }
137+
132138 let source_text = source_text. or_else ( || read_to_string ( path) . ok ( ) ) ?;
133139
134140 debug ! ( "lint {}" , path. display( ) ) ;
0 commit comments