From 220d285b4afb250e59a08e9b1ad38c2fc2275782 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 25 Aug 2018 11:44:58 +0300 Subject: rename ParsedFile -> File --- crates/libeditor/src/code_actions.rs | 8 ++++---- crates/libeditor/src/extend_selection.rs | 4 ++-- crates/libeditor/src/lib.rs | 16 ++++++++-------- crates/libeditor/src/symbols.rs | 6 +++--- crates/libeditor/src/typing.rs | 4 ++-- crates/libeditor/tests/test.rs | 8 ++++---- 6 files changed, 23 insertions(+), 23 deletions(-) (limited to 'crates/libeditor') diff --git a/crates/libeditor/src/code_actions.rs b/crates/libeditor/src/code_actions.rs index c7c043b39..b3305be2a 100644 --- a/crates/libeditor/src/code_actions.rs +++ b/crates/libeditor/src/code_actions.rs @@ -3,7 +3,7 @@ use std::{ }; use libsyntax2::{ - ParsedFile, + File, ast::{self, AstNode, AttrsOwner, TypeParamsOwner, NameOwner}, SyntaxKind::COMMA, SyntaxNodeRef, @@ -21,7 +21,7 @@ pub struct ActionResult { pub cursor_position: Option, } -pub fn flip_comma<'a>(file: &'a ParsedFile, offset: TextUnit) -> Option ActionResult + 'a> { +pub fn flip_comma<'a>(file: &'a File, offset: TextUnit) -> Option ActionResult + 'a> { let syntax = file.syntax(); let comma = find_leaf_at_offset(syntax, offset).find(|leaf| leaf.kind() == COMMA)?; @@ -38,7 +38,7 @@ pub fn flip_comma<'a>(file: &'a ParsedFile, offset: TextUnit) -> Option(file: &'a ParsedFile, offset: TextUnit) -> Option ActionResult + 'a> { +pub fn add_derive<'a>(file: &'a File, offset: TextUnit) -> Option ActionResult + 'a> { let nominal = find_node::(file.syntax(), offset)?; Some(move || { let derive_attr = nominal @@ -65,7 +65,7 @@ pub fn add_derive<'a>(file: &'a ParsedFile, offset: TextUnit) -> Option(file: &'a ParsedFile, offset: TextUnit) -> Option ActionResult + 'a> { +pub fn add_impl<'a>(file: &'a File, offset: TextUnit) -> Option ActionResult + 'a> { let nominal = find_node::(file.syntax(), offset)?; let name = nominal.name()?; diff --git a/crates/libeditor/src/extend_selection.rs b/crates/libeditor/src/extend_selection.rs index 32873f491..d1724b528 100644 --- a/crates/libeditor/src/extend_selection.rs +++ b/crates/libeditor/src/extend_selection.rs @@ -1,10 +1,10 @@ use libsyntax2::{ - ParsedFile, TextRange, SyntaxNodeRef, + File, TextRange, SyntaxNodeRef, SyntaxKind::WHITESPACE, algo::{find_leaf_at_offset, find_covering_node, ancestors}, }; -pub fn extend_selection(file: &ParsedFile, range: TextRange) -> Option { +pub fn extend_selection(file: &File, range: TextRange) -> Option { let syntax = file.syntax(); extend(syntax.borrowed(), range) } diff --git a/crates/libeditor/src/lib.rs b/crates/libeditor/src/lib.rs index 681cca81d..a6e6deba7 100644 --- a/crates/libeditor/src/lib.rs +++ b/crates/libeditor/src/lib.rs @@ -14,7 +14,7 @@ use libsyntax2::{ algo::{walk, find_leaf_at_offset}, SyntaxKind::{self, *}, }; -pub use libsyntax2::{ParsedFile, TextRange, TextUnit}; +pub use libsyntax2::{File, TextRange, TextUnit}; pub use self::{ line_index::{LineIndex, LineCol}, extend_selection::extend_selection, @@ -51,11 +51,11 @@ pub enum RunnableKind { Bin, } -pub fn parse(text: &str) -> ParsedFile { - ParsedFile::parse(text) +pub fn parse(text: &str) -> File { + File::parse(text) } -pub fn matching_brace(file: &ParsedFile, offset: TextUnit) -> Option { +pub fn matching_brace(file: &File, offset: TextUnit) -> Option { const BRACES: &[SyntaxKind] = &[ L_CURLY, R_CURLY, L_BRACK, R_BRACK, @@ -75,7 +75,7 @@ pub fn matching_brace(file: &ParsedFile, offset: TextUnit) -> Option { Some(matching_node.range().start()) } -pub fn highlight(file: &ParsedFile) -> Vec { +pub fn highlight(file: &File) -> Vec { let mut res = Vec::new(); for node in walk::preorder(file.syntax()) { let tag = match node.kind() { @@ -98,7 +98,7 @@ pub fn highlight(file: &ParsedFile) -> Vec { res } -pub fn diagnostics(file: &ParsedFile) -> Vec { +pub fn diagnostics(file: &File) -> Vec { let mut res = Vec::new(); for node in walk::preorder(file.syntax()) { @@ -116,11 +116,11 @@ pub fn diagnostics(file: &ParsedFile) -> Vec { res } -pub fn syntax_tree(file: &ParsedFile) -> String { +pub fn syntax_tree(file: &File) -> String { ::libsyntax2::utils::dump_tree(file.syntax()) } -pub fn runnables(file: &ParsedFile) -> Vec { +pub fn runnables(file: &File) -> Vec { file.ast() .functions() .filter_map(|f| { diff --git a/crates/libeditor/src/symbols.rs b/crates/libeditor/src/symbols.rs index 37cef6389..98a35dcdf 100644 --- a/crates/libeditor/src/symbols.rs +++ b/crates/libeditor/src/symbols.rs @@ -1,5 +1,5 @@ use libsyntax2::{ - SyntaxKind, SyntaxNodeRef, AstNode, ParsedFile, SmolStr, + SyntaxKind, SyntaxNodeRef, AstNode, File, SmolStr, ast::{self, NameOwner}, algo::{ visit::{visitor, Visitor}, @@ -24,7 +24,7 @@ pub struct FileSymbol { pub kind: SyntaxKind, } -pub fn file_symbols(file: &ParsedFile) -> Vec { +pub fn file_symbols(file: &File) -> Vec { preorder(file.syntax()) .filter_map(to_symbol) .collect() @@ -52,7 +52,7 @@ fn to_symbol(node: SyntaxNodeRef) -> Option { } -pub fn file_structure(file: &ParsedFile) -> Vec { +pub fn file_structure(file: &File) -> Vec { let mut res = Vec::new(); let mut stack = Vec::new(); diff --git a/crates/libeditor/src/typing.rs b/crates/libeditor/src/typing.rs index ebc7c77d2..e7eba671f 100644 --- a/crates/libeditor/src/typing.rs +++ b/crates/libeditor/src/typing.rs @@ -1,5 +1,5 @@ use libsyntax2::{ - TextUnit, TextRange, SyntaxNodeRef, ParsedFile, + TextUnit, TextRange, SyntaxNodeRef, File, algo::{ walk::preorder, find_covering_node, @@ -10,7 +10,7 @@ use libsyntax2::{ use {ActionResult, EditBuilder}; -pub fn join_lines(file: &ParsedFile, range: TextRange) -> ActionResult { +pub fn join_lines(file: &File, range: TextRange) -> ActionResult { let range = if range.is_empty() { let text = file.syntax().text(); let text = &text[TextRange::from_to(range.start(), TextUnit::of_str(&text))]; diff --git a/crates/libeditor/tests/test.rs b/crates/libeditor/tests/test.rs index 4f7c2e07a..3114a128e 100644 --- a/crates/libeditor/tests/test.rs +++ b/crates/libeditor/tests/test.rs @@ -5,7 +5,7 @@ extern crate assert_eq_text; use assert_eq_text::{assert_eq_dbg}; use libeditor::{ - ParsedFile, TextUnit, TextRange, ActionResult, + File, TextUnit, TextRange, ActionResult, highlight, runnables, extend_selection, file_structure, flip_comma, add_derive, add_impl, matching_brace, join_lines, @@ -234,11 +234,11 @@ struct Foo { f: u32 } "); } -fn file(text: &str) -> ParsedFile { - ParsedFile::parse(text) +fn file(text: &str) -> File { + File::parse(text) } -fn check_action Option>( +fn check_action Option>( before: &str, after: &str, f: F, -- cgit v1.2.3