Create modules via SourceBinder

This commit is contained in:
Aleksey Kladov 2020-01-16 17:33:07 +01:00
parent 9a6c26e348
commit 595b06a1b8
10 changed files with 65 additions and 112 deletions

View file

@ -23,6 +23,7 @@ pub enum Severity {
pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic> {
let _p = profile("diagnostics");
let mut sb = hir::SourceBinder::new(db);
let parse = db.parse(file_id);
let mut res = Vec::new();
@ -108,10 +109,7 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic>
fix: Some(fix),
})
});
let source_file = db.parse(file_id).tree();
let src =
hir::InFile { file_id: file_id.into(), value: hir::ModuleSource::SourceFile(source_file) };
if let Some(m) = hir::Module::from_definition(db, src) {
if let Some(m) = sb.to_module_def(file_id) {
m.diagnostics(db, &mut sink);
};
drop(sink);