1 //! Various batch processing tasks, intended primarily for debugging.
12 use ra_ide::{file_structure, Analysis};
14 use ra_syntax::{AstNode, SourceFile};
16 pub use analysis_bench::{analysis_bench, BenchWhat, Position};
17 pub use analysis_stats::analysis_stats;
18 pub use diagnostics::diagnostics;
19 pub use load_cargo::load_cargo;
21 #[derive(Clone, Copy)]
30 pub fn is_verbose(self) -> bool {
32 Verbosity::Verbose | Verbosity::Spammy => true,
36 pub fn is_spammy(self) -> bool {
38 Verbosity::Spammy => true,
44 pub fn parse(no_dump: bool) -> Result<()> {
45 let _p = profile("parsing");
48 println!("{:#?}", file.syntax());
50 std::mem::forget(file);
54 pub fn symbols() -> Result<()> {
56 for s in file_structure(&file) {
62 pub fn highlight(rainbow: bool) -> Result<()> {
63 let (analysis, file_id) = Analysis::from_single_file(read_stdin()?);
64 let html = analysis.highlight_as_html(file_id, rainbow).unwrap();
69 fn file() -> Result<SourceFile> {
70 let text = read_stdin()?;
71 Ok(SourceFile::parse(&text).tree())
74 fn read_stdin() -> Result<String> {
75 let mut buff = String::new();
76 std::io::stdin().read_to_string(&mut buff)?;