From 2195d1db6d70d64383bec82819fab02891d09744 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 13 Mar 2019 16:38:02 +0300 Subject: Replace module_tree with CrateDefMap --- crates/ra_ide_api/src/runnables.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_ide_api/src') diff --git a/crates/ra_ide_api/src/runnables.rs b/crates/ra_ide_api/src/runnables.rs index d64b5a4e0..2395930f0 100644 --- a/crates/ra_ide_api/src/runnables.rs +++ b/crates/ra_ide_api/src/runnables.rs @@ -1,7 +1,7 @@ use itertools::Itertools; use ra_syntax::{ TextRange, SyntaxNode, - ast::{self, AstNode, NameOwner, ModuleItemOwner}, + ast::{self, AstNode, NameOwner, ModuleItemOwner, AttrsOwner}, }; use ra_db::SourceDatabase; -- cgit v1.2.3 From b2a6c1736295a5fffa5ac0d0fee835cdc719ada3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 14 Mar 2019 13:14:54 +0300 Subject: remove lower module --- crates/ra_ide_api/src/change.rs | 2 +- crates/ra_ide_api/src/symbol_index.rs | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) (limited to 'crates/ra_ide_api/src') diff --git a/crates/ra_ide_api/src/change.rs b/crates/ra_ide_api/src/change.rs index 0c90ed5b5..26fde91bc 100644 --- a/crates/ra_ide_api/src/change.rs +++ b/crates/ra_ide_api/src/change.rs @@ -223,7 +223,7 @@ impl RootDatabase { self.query(hir::db::FileItemsQuery).sweep(sweep); self.query(hir::db::FileItemQuery).sweep(sweep); - self.query(hir::db::LowerModuleWithSourceMapQuery).sweep(sweep); + self.query(hir::db::RawItemsWithSourceMapQuery).sweep(sweep); self.query(hir::db::BodyWithSourceMapQuery).sweep(sweep); } } diff --git a/crates/ra_ide_api/src/symbol_index.rs b/crates/ra_ide_api/src/symbol_index.rs index 94fe1d6d7..23c743bef 100644 --- a/crates/ra_ide_api/src/symbol_index.rs +++ b/crates/ra_ide_api/src/symbol_index.rs @@ -30,7 +30,7 @@ use std::{ use fst::{self, Streamer}; use ra_syntax::{ SyntaxNode, SyntaxNodePtr, SourceFile, SmolStr, TreeArc, AstNode, - algo::{visit::{visitor, Visitor}, find_covering_node}, + algo::{visit::{visitor, Visitor}}, SyntaxKind::{self, *}, ast::{self, NameOwner}, WalkEvent, @@ -66,14 +66,9 @@ fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Arc db.check_canceled(); let source_file = db.parse(file_id); - let mut symbols = source_file_to_file_symbols(&source_file, file_id); + let symbols = source_file_to_file_symbols(&source_file, file_id); - for (name, text_range) in hir::source_binder::macro_symbols(db, file_id) { - let node = find_covering_node(source_file.syntax(), text_range); - let ptr = SyntaxNodePtr::new(node); - // TODO: Should we get container name for macro symbols? - symbols.push(FileSymbol { file_id, name, ptr, name_range: None, container_name: None }) - } + // TODO: add macros here Arc::new(SymbolIndex::new(symbols)) } -- cgit v1.2.3 From 6955e392f8c1cd49e769328b14e10b84ede26744 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 16 Mar 2019 19:40:41 +0300 Subject: remove old macro support --- crates/ra_ide_api/src/extend_selection.rs | 46 ++-------------------------- crates/ra_ide_api/src/syntax_highlighting.rs | 36 ++-------------------- 2 files changed, 4 insertions(+), 78 deletions(-) (limited to 'crates/ra_ide_api/src') diff --git a/crates/ra_ide_api/src/extend_selection.rs b/crates/ra_ide_api/src/extend_selection.rs index 4051728e1..d23290b74 100644 --- a/crates/ra_ide_api/src/extend_selection.rs +++ b/crates/ra_ide_api/src/extend_selection.rs @@ -1,55 +1,13 @@ use ra_db::SourceDatabase; -use ra_syntax::{ - SyntaxNode, AstNode, SourceFile, - ast, algo::find_covering_node, -}; +use ra_syntax::AstNode; use crate::{ TextRange, FileRange, db::RootDatabase, }; +// FIXME: restore macro support pub(crate) fn extend_selection(db: &RootDatabase, frange: FileRange) -> TextRange { let source_file = db.parse(frange.file_id); - if let Some(range) = extend_selection_in_macro(db, &source_file, frange) { - return range; - } ra_ide_api_light::extend_selection(source_file.syntax(), frange.range).unwrap_or(frange.range) } - -fn extend_selection_in_macro( - _db: &RootDatabase, - source_file: &SourceFile, - frange: FileRange, -) -> Option { - let macro_call = find_macro_call(source_file.syntax(), frange.range)?; - let (off, exp) = hir::MacroDef::ast_expand(macro_call)?; - let dst_range = exp.map_range_forward(frange.range - off)?; - let dst_range = ra_ide_api_light::extend_selection(&exp.syntax(), dst_range)?; - let src_range = exp.map_range_back(dst_range)? + off; - Some(src_range) -} - -fn find_macro_call(node: &SyntaxNode, range: TextRange) -> Option<&ast::MacroCall> { - find_covering_node(node, range).ancestors().find_map(ast::MacroCall::cast) -} - -#[cfg(test)] -mod tests { - use ra_syntax::TextRange; - - use crate::mock_analysis::single_file_with_range; - - #[test] - fn extend_selection_inside_macros() { - let (analysis, frange) = single_file_with_range( - " - fn main() { - vec![foo(|x| <|>x<|>)]; - } - ", - ); - let r = analysis.extend_selection(frange).unwrap(); - assert_eq!(r, TextRange::from_to(50.into(), 55.into())); - } -} diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs index 345b6653d..fdd87bcff 100644 --- a/crates/ra_ide_api/src/syntax_highlighting.rs +++ b/crates/ra_ide_api/src/syntax_highlighting.rs @@ -1,4 +1,4 @@ -use ra_syntax::{ast, AstNode,}; +use ra_syntax::AstNode; use ra_db::SourceDatabase; use crate::{ @@ -8,37 +8,5 @@ use crate::{ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec { let source_file = db.parse(file_id); - let mut res = ra_ide_api_light::highlight(source_file.syntax()); - for macro_call in source_file.syntax().descendants().filter_map(ast::MacroCall::cast) { - if let Some((off, exp)) = hir::MacroDef::ast_expand(macro_call) { - let mapped_ranges = - ra_ide_api_light::highlight(&exp.syntax()).into_iter().filter_map(|r| { - let mapped_range = exp.map_range_back(r.range)?; - let res = HighlightedRange { range: mapped_range + off, tag: r.tag }; - Some(res) - }); - res.extend(mapped_ranges); - } - } - res -} - -#[cfg(test)] -mod tests { - use crate::mock_analysis::single_file; - - use insta::assert_debug_snapshot_matches; - - #[test] - fn highlights_code_inside_macros() { - let (analysis, file_id) = single_file( - " - fn main() { - vec![{ let x = 92; x}]; - } - ", - ); - let highlights = analysis.highlight(file_id).unwrap(); - assert_debug_snapshot_matches!("highlights_code_inside_macros", &highlights); - } + ra_ide_api_light::highlight(source_file.syntax()) } -- cgit v1.2.3