migrate ra_cli to new rowan

This commit is contained in:
Aleksey Kladov 2019-01-07 17:06:54 +03:00
parent fe53b28250
commit d6020f516f

View file

@ -3,7 +3,7 @@ use std::{fs, io::Read, path::Path, time::Instant};
use clap::{App, Arg, SubCommand};
use join_to_string::join;
use ra_editor::{extend_selection, file_structure, syntax_tree};
use ra_syntax::{SourceFileNode, TextRange};
use ra_syntax::{SourceFile, TextRange, TreePtr, AstNode};
use tools::collect_tests;
type Result<T> = ::std::result::Result<T, failure::Error>;
@ -71,9 +71,9 @@ fn main() -> Result<()> {
Ok(())
}
fn file() -> Result<SourceFileNode> {
fn file() -> Result<TreePtr<SourceFile>> {
let text = read_stdin()?;
Ok(SourceFileNode::parse(&text))
Ok(SourceFile::parse(&text))
}
fn read_stdin() -> Result<String> {
@ -92,12 +92,12 @@ fn render_test(file: &Path, line: usize) -> Result<(String, String)> {
None => failure::bail!("No test found at line {} at {}", line, file.display()),
Some((_start_line, test)) => test,
};
let file = SourceFileNode::parse(&test.text);
let file = SourceFile::parse(&test.text);
let tree = syntax_tree(&file);
Ok((test.text, tree))
}
fn selections(file: &SourceFileNode, start: u32, end: u32) -> String {
fn selections(file: &SourceFile, start: u32, end: u32) -> String {
let mut ranges = Vec::new();
let mut cur = Some(TextRange::from_to((start - 1).into(), (end - 1).into()));
while let Some(r) = cur {