This commit is contained in:
Aleksey Kladov 2018-08-11 08:56:13 +03:00
parent f99551f46b
commit 35b59bb438
3 changed files with 13 additions and 8 deletions

View file

@ -10,7 +10,7 @@ use std::{
};
use clap::{App, Arg, SubCommand};
use tools::collect_tests;
use libeditor::{ast, syntax_tree, symbols};
use libeditor::{File, syntax_tree, symbols};
type Result<T> = ::std::result::Result<T, failure::Error>;
@ -68,9 +68,9 @@ fn main() -> Result<()> {
Ok(())
}
fn file() -> Result<ast::File> {
fn file() -> Result<File> {
let text = read_stdin()?;
Ok(ast::File::parse(&text))
Ok(libeditor::parse(&text))
}
fn read_stdin() -> Result<String> {
@ -89,7 +89,7 @@ fn render_test(file: &Path, line: usize) -> Result<(String, String)> {
None => bail!("No test found at line {} at {}", line, file.display()),
Some((_start_line, test)) => test,
};
let file = ast::File::parse(&test.text);
let file = libeditor::parse(&test.text);
let tree = syntax_tree(&file);
Ok((test.text, tree))
}

View file

@ -5,11 +5,12 @@ mod extend_selection;
mod line_index;
use libsyntax2::{
ast,
SyntaxNodeRef, AstNode,
algo::walk,
SyntaxKind::*,
};
pub use libsyntax2::{TextRange, TextUnit, ast};
pub use libsyntax2::{File, TextRange, TextUnit};
pub use self::line_index::{LineIndex, LineCol};
#[derive(Debug)]
@ -43,6 +44,10 @@ pub enum RunnableKind {
Bin,
}
pub fn parse(text: &str) -> ast::File {
ast::File::parse(text)
}
pub fn highlight(file: &ast::File) -> Vec<HighlightedRange> {
let syntax = file.syntax();
let mut res = Vec::new();

View file

@ -3,7 +3,7 @@ extern crate itertools;
use std::fmt;
use itertools::Itertools;
use libeditor::{ast, highlight, runnables, extend_selection, TextRange};
use libeditor::{File, highlight, runnables, extend_selection, TextRange};
#[test]
fn test_extend_selection() {
@ -58,8 +58,8 @@ fn test_foo() {}
)
}
fn file(text: &str) -> ast::File {
ast::File::parse(text)
fn file(text: &str) -> File {
File::parse(text)
}
fn dbg_eq(actual: &impl fmt::Debug, expected: &str) {