From 35b59bb43877c496fbaf98520b3b52ff9a6518b1 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 11 Aug 2018 08:56:13 +0300 Subject: simplify --- crates/libeditor/src/lib.rs | 7 ++++++- crates/libeditor/tests/test.rs | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'crates/libeditor') diff --git a/crates/libeditor/src/lib.rs b/crates/libeditor/src/lib.rs index f77647338..c762a8b0b 100644 --- a/crates/libeditor/src/lib.rs +++ b/crates/libeditor/src/lib.rs @@ -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 { let syntax = file.syntax(); let mut res = Vec::new(); diff --git a/crates/libeditor/tests/test.rs b/crates/libeditor/tests/test.rs index 2a84c5080..d617f4b99 100644 --- a/crates/libeditor/tests/test.rs +++ b/crates/libeditor/tests/test.rs @@ -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) { -- cgit v1.2.3