mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
introduce FromSource trait
This commit is contained in:
parent
c35ef7e1ed
commit
2867c40925
13 changed files with 294 additions and 138 deletions
|
@ -1,9 +1,6 @@
|
|||
use std::cell::RefCell;
|
||||
|
||||
use hir::{
|
||||
diagnostics::{AstDiagnostic, Diagnostic as _, DiagnosticSink},
|
||||
source_binder,
|
||||
};
|
||||
use hir::diagnostics::{AstDiagnostic, Diagnostic as _, DiagnosticSink};
|
||||
use itertools::Itertools;
|
||||
use ra_assists::ast_editor::{AstBuilder, AstEditor};
|
||||
use ra_db::SourceDatabase;
|
||||
|
@ -89,7 +86,10 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic>
|
|||
fix: Some(fix),
|
||||
})
|
||||
});
|
||||
if let Some(m) = source_binder::module_from_file_id(db, file_id) {
|
||||
let source_file = db.parse(file_id).tree().to_owned();
|
||||
let src =
|
||||
hir::Source { file_id: file_id.into(), ast: hir::ModuleSource::SourceFile(source_file) };
|
||||
if let Some(m) = hir::Module::from_definition(db, src) {
|
||||
m.diagnostics(db, &mut sink);
|
||||
};
|
||||
drop(sink);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue