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
1 changed files with 5 additions and 5 deletions

View File

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