From 9e213385c9d06db3c8ca20812779e2b8f8ad2c71 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 30 Mar 2019 13:25:53 +0300 Subject: switch to new rowan --- crates/ra_cli/src/analysis_stats.rs | 7 +++++-- crates/ra_cli/src/main.rs | 35 +---------------------------------- 2 files changed, 6 insertions(+), 36 deletions(-) (limited to 'crates/ra_cli/src') diff --git a/crates/ra_cli/src/analysis_stats.rs b/crates/ra_cli/src/analysis_stats.rs index ee410c548..4516ed660 100644 --- a/crates/ra_cli/src/analysis_stats.rs +++ b/crates/ra_cli/src/analysis_stats.rs @@ -1,4 +1,4 @@ -use std::collections::HashSet; +use std::{collections::HashSet, time::Instant}; use ra_db::SourceDatabase; use ra_batch::BatchDatabase; @@ -8,8 +8,10 @@ use ra_syntax::AstNode; use crate::Result; pub fn run(verbose: bool) -> Result<()> { + let db_load_time = Instant::now(); let (db, roots) = BatchDatabase::load_cargo(".")?; - println!("Database loaded, {} roots", roots.len()); + println!("Database loaded, {} roots, {:?}", roots.len(), db_load_time.elapsed()); + let analysis_time = Instant::now(); let mut num_crates = 0; let mut visited_modules = HashSet::new(); let mut visit_queue = Vec::new(); @@ -96,5 +98,6 @@ pub fn run(verbose: bool) -> Result<()> { num_exprs_partially_unknown, (num_exprs_partially_unknown * 100 / num_exprs) ); + println!("Analysis: {:?}", analysis_time.elapsed()); Ok(()) } diff --git a/crates/ra_cli/src/main.rs b/crates/ra_cli/src/main.rs index 11f5541eb..1f2750d89 100644 --- a/crates/ra_cli/src/main.rs +++ b/crates/ra_cli/src/main.rs @@ -3,10 +3,8 @@ mod analysis_stats; use std::{fs, io::Read, path::Path, time::Instant}; use clap::{App, Arg, SubCommand}; -use join_to_string::join; -use ra_ide_api::{Analysis, FileRange}; use ra_ide_api::file_structure; -use ra_syntax::{SourceFile, TextRange, TreeArc, AstNode}; +use ra_syntax::{SourceFile, TreeArc, AstNode}; use tools::collect_tests; use flexi_logger::Logger; @@ -23,11 +21,6 @@ fn main() -> Result<()> { ) .subcommand(SubCommand::with_name("parse").arg(Arg::with_name("no-dump").long("--no-dump"))) .subcommand(SubCommand::with_name("symbols")) - .subcommand( - SubCommand::with_name("extend-selection") - .arg(Arg::with_name("start")) - .arg(Arg::with_name("end")), - ) .subcommand( SubCommand::with_name("analysis-stats").arg(Arg::with_name("verbose").short("v")), ) @@ -57,13 +50,6 @@ fn main() -> Result<()> { let (test, tree) = render_test(file, line)?; println!("{}\n{}", test, tree); } - ("extend-selection", Some(matches)) => { - let start: u32 = matches.value_of("start").unwrap().parse()?; - let end: u32 = matches.value_of("end").unwrap().parse()?; - let text = read_stdin()?; - let sels = selections(text, start, end); - println!("{}", sels) - } ("analysis-stats", Some(matches)) => { let verbose = matches.is_present("verbose"); analysis_stats::run(verbose)?; @@ -98,22 +84,3 @@ fn render_test(file: &Path, line: usize) -> Result<(String, String)> { let tree = file.syntax().debug_dump(); Ok((test.text, tree)) } - -fn selections(text: String, start: u32, end: u32) -> String { - let (analysis, file_id) = Analysis::from_single_file(text); - let mut ranges = Vec::new(); - let mut range = TextRange::from_to((start - 1).into(), (end - 1).into()); - loop { - ranges.push(range); - let next = analysis.extend_selection(FileRange { file_id, range }).unwrap(); - if range == next { - break; - } - range = next; - } - let ranges = ranges - .iter() - .map(|r| (1 + u32::from(r.start()), 1 + u32::from(r.end()))) - .map(|(s, e)| format!("({} {})", s, e)); - join(ranges).separator(" ").surround_with("(", ")").to_string() -} -- cgit v1.2.3