about summary refs log tree commit diff
path: root/crates/rust-analyzer/src/cli/parse.rs
blob: 5ef8cdff4cf25173dea29ce4395cd289b1cb5df3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Read Rust code on stdin, print syntax tree on stdout.
use syntax::{AstNode, SourceFile};

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

impl flags::Parse {
    pub fn run(self) -> anyhow::Result<()> {
        let _p = profile::span("parsing");
        let text = read_stdin()?;
        let file = SourceFile::parse(&text).tree();
        if !self.no_dump {
            println!("{:#?}", file.syntax());
        }
        std::mem::forget(file);
        Ok(())
    }
}