@@ -21,12 +21,11 @@ use std::borrow::Cow;
2121use std:: path:: { Path , PathBuf } ;
2222use triomphe:: Arc ;
2323pub enum RustAnalyzer < ' a > {
24- WithDatabase {
25- db : & ' a RootDatabase ,
24+ WithSemantics {
2625 vfs : & ' a Vfs ,
2726 semantics : Semantics < ' a , RootDatabase > ,
2827 } ,
29- WithoutDatabase ( ) ,
28+ WithoutSemantics ,
3029}
3130pub struct ParseResult {
3231 pub ast : SourceFile ,
@@ -62,31 +61,28 @@ impl<'a> RustAnalyzer<'a> {
6261 }
6362 }
6463 }
65- pub fn new ( db : & ' a RootDatabase , vfs : & ' a Vfs , semantics : Semantics < ' a , RootDatabase > ) -> Self {
66- RustAnalyzer :: WithDatabase { db , vfs, semantics }
64+ pub fn new ( vfs : & ' a Vfs , semantics : Semantics < ' a , RootDatabase > ) -> Self {
65+ RustAnalyzer :: WithSemantics { vfs, semantics }
6766 }
6867 pub fn semantics ( & ' a self ) -> Option < & ' a Semantics < ' a , RootDatabase > > {
6968 match self {
70- RustAnalyzer :: WithDatabase {
71- db : _,
72- vfs : _,
73- semantics,
74- } => Some ( semantics) ,
75- RustAnalyzer :: WithoutDatabase ( ) => None ,
69+ RustAnalyzer :: WithSemantics { vfs : _, semantics } => Some ( semantics) ,
70+ RustAnalyzer :: WithoutSemantics => None ,
7671 }
7772 }
7873 pub fn parse ( & self , path : & Path ) -> ParseResult {
79- if let RustAnalyzer :: WithDatabase { vfs, db , semantics } = self {
74+ if let RustAnalyzer :: WithSemantics { vfs, semantics } = self {
8075 if let Some ( file_id) = Utf8PathBuf :: from_path_buf ( path. to_path_buf ( ) )
8176 . ok ( )
8277 . and_then ( |x| AbsPathBuf :: try_from ( x) . ok ( ) )
8378 . map ( VfsPath :: from)
8479 . and_then ( |x| vfs. file_id ( & x) )
8580 {
86- let input: Arc < str > = db. file_text ( file_id) ;
81+ let input: Arc < str > = semantics . db . file_text ( file_id) ;
8782 let file_id = EditionedFileId :: current_edition ( file_id) ;
8883 let source_file = semantics. parse ( file_id) ;
89- let errors = db
84+ let errors = semantics
85+ . db
9086 . parse_errors ( file_id)
9187 . into_iter ( )
9288 . flat_map ( |x| x. to_vec ( ) )
0 commit comments