From c3a4c4429de83450654795534e64e878a774a088 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 18 Feb 2020 18:35:10 +0100 Subject: Refactor primary IDE API This introduces the new type -- Semantics. Semantics maps SyntaxNodes to various semantic info, such as type, name resolution or macro expansions. To do so, Semantics maintains a HashMap which maps every node it saw to the file from which the node originated. This is enough to get all the necessary hir bits just from syntax. --- crates/ra_ide/src/diagnostics.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'crates/ra_ide/src/diagnostics.rs') diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index 9cf86b26d..a52f7fdd9 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -2,7 +2,10 @@ use std::cell::RefCell; -use hir::diagnostics::{AstDiagnostic, Diagnostic as _, DiagnosticSink}; +use hir::{ + diagnostics::{AstDiagnostic, Diagnostic as _, DiagnosticSink}, + Semantics, +}; use itertools::Itertools; use ra_db::{RelativePath, SourceDatabase, SourceDatabaseExt}; use ra_ide_db::RootDatabase; @@ -24,7 +27,7 @@ pub enum Severity { pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec { let _p = profile("diagnostics"); - let mut sb = hir::SourceBinder::new(db); + let sema = Semantics::new(db); let parse = db.parse(file_id); let mut res = Vec::new(); @@ -110,7 +113,7 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec fix: Some(fix), }) }); - if let Some(m) = sb.to_module_def(file_id) { + if let Some(m) = sema.to_module_def(file_id) { m.diagnostics(db, &mut sink); }; drop(sink); -- cgit v1.2.3