rust_analyzer/cli/
symbols.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! Read Rust code on stdin, print syntax tree on stdout.
use ide::Analysis;

use crate::cli::{flags, read_stdin};

impl flags::Symbols {
    pub fn run(self) -> anyhow::Result<()> {
        let text = read_stdin()?;
        let (analysis, file_id) = Analysis::from_single_file(text);
        let structure = analysis.file_structure(file_id).unwrap();
        for s in structure {
            println!("{s:?}");
        }
        Ok(())
    }
}