From 50a02eb3593591a02677e1b56f24d7ff0459b9d0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 12 Aug 2020 17:06:49 +0200 Subject: Rename ra_parser -> parser --- crates/ra_syntax/src/ast/node_ext.rs | 2 +- crates/ra_syntax/src/lib.rs | 14 +++++++------- crates/ra_syntax/src/parsing.rs | 14 +++++++------- crates/ra_syntax/src/parsing/reparsing.rs | 2 +- crates/ra_syntax/src/parsing/text_token_source.rs | 14 +++++++------- crates/ra_syntax/src/parsing/text_tree_sink.rs | 2 +- crates/ra_syntax/src/syntax_node.rs | 2 +- 7 files changed, 25 insertions(+), 25 deletions(-) (limited to 'crates/ra_syntax/src') diff --git a/crates/ra_syntax/src/ast/node_ext.rs b/crates/ra_syntax/src/ast/node_ext.rs index 733e97877..50c1c157d 100644 --- a/crates/ra_syntax/src/ast/node_ext.rs +++ b/crates/ra_syntax/src/ast/node_ext.rs @@ -4,7 +4,7 @@ use std::fmt; use itertools::Itertools; -use ra_parser::SyntaxKind; +use parser::SyntaxKind; use crate::{ ast::{self, support, AstNode, NameOwner, SyntaxNode}, diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index 465607f55..7f8da66af 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs @@ -11,7 +11,7 @@ //! //! The most interesting modules here are `syntax_node` (which defines concrete //! syntax tree) and `ast` (which defines abstract syntax tree on top of the -//! CST). The actual parser live in a separate `ra_parser` crate, though the +//! CST). The actual parser live in a separate `parser` crate, though the //! lexer lives in this crate. //! //! See `api_walkthrough` test in this file for a quick API tour! @@ -53,7 +53,7 @@ pub use crate::{ SyntaxNodeChildren, SyntaxToken, SyntaxTreeBuilder, }, }; -pub use ra_parser::{SyntaxKind, T}; +pub use parser::{SyntaxKind, T}; pub use rowan::{SmolStr, SyntaxText, TextRange, TextSize, TokenAtOffset, WalkEvent}; /// `Parse` is the result of the parsing: a syntax tree and a collection of @@ -169,35 +169,35 @@ impl SourceFile { impl ast::Path { /// Returns `text`, parsed as a path, but only if it has no errors. pub fn parse(text: &str) -> Result { - parsing::parse_text_fragment(text, ra_parser::FragmentKind::Path) + parsing::parse_text_fragment(text, parser::FragmentKind::Path) } } impl ast::Pat { /// Returns `text`, parsed as a pattern, but only if it has no errors. pub fn parse(text: &str) -> Result { - parsing::parse_text_fragment(text, ra_parser::FragmentKind::Pattern) + parsing::parse_text_fragment(text, parser::FragmentKind::Pattern) } } impl ast::Expr { /// Returns `text`, parsed as an expression, but only if it has no errors. pub fn parse(text: &str) -> Result { - parsing::parse_text_fragment(text, ra_parser::FragmentKind::Expr) + parsing::parse_text_fragment(text, parser::FragmentKind::Expr) } } impl ast::Item { /// Returns `text`, parsed as an item, but only if it has no errors. pub fn parse(text: &str) -> Result { - parsing::parse_text_fragment(text, ra_parser::FragmentKind::Item) + parsing::parse_text_fragment(text, parser::FragmentKind::Item) } } impl ast::Type { /// Returns `text`, parsed as an type reference, but only if it has no errors. pub fn parse(text: &str) -> Result { - parsing::parse_text_fragment(text, ra_parser::FragmentKind::Type) + parsing::parse_text_fragment(text, parser::FragmentKind::Type) } } diff --git a/crates/ra_syntax/src/parsing.rs b/crates/ra_syntax/src/parsing.rs index 0ed3c20ef..68a39eb21 100644 --- a/crates/ra_syntax/src/parsing.rs +++ b/crates/ra_syntax/src/parsing.rs @@ -1,4 +1,4 @@ -//! Lexing, bridging to ra_parser (which does the actual parsing) and +//! Lexing, bridging to parser (which does the actual parsing) and //! incremental reparsing. mod lexer; @@ -13,7 +13,7 @@ use text_tree_sink::TextTreeSink; pub use lexer::*; pub(crate) use self::reparsing::incremental_reparse; -use ra_parser::SyntaxKind; +use parser::SyntaxKind; pub(crate) fn parse_text(text: &str) -> (GreenNode, Vec) { let (tokens, lexer_errors) = tokenize(&text); @@ -21,7 +21,7 @@ pub(crate) fn parse_text(text: &str) -> (GreenNode, Vec) { let mut token_source = TextTokenSource::new(text, &tokens); let mut tree_sink = TextTreeSink::new(text, &tokens); - ra_parser::parse(&mut token_source, &mut tree_sink); + parser::parse(&mut token_source, &mut tree_sink); let (tree, mut parser_errors) = tree_sink.finish(); parser_errors.extend(lexer_errors); @@ -32,7 +32,7 @@ pub(crate) fn parse_text(text: &str) -> (GreenNode, Vec) { /// Returns `text` parsed as a `T` provided there are no parse errors. pub(crate) fn parse_text_fragment( text: &str, - fragment_kind: ra_parser::FragmentKind, + fragment_kind: parser::FragmentKind, ) -> Result { let (tokens, lexer_errors) = tokenize(&text); if !lexer_errors.is_empty() { @@ -44,13 +44,13 @@ pub(crate) fn parse_text_fragment( // TextTreeSink assumes that there's at least some root node to which it can attach errors and // tokens. We arbitrarily give it a SourceFile. - use ra_parser::TreeSink; + use parser::TreeSink; tree_sink.start_node(SyntaxKind::SOURCE_FILE); - ra_parser::parse_fragment(&mut token_source, &mut tree_sink, fragment_kind); + parser::parse_fragment(&mut token_source, &mut tree_sink, fragment_kind); tree_sink.finish_node(); let (tree, parser_errors) = tree_sink.finish(); - use ra_parser::TokenSource; + use parser::TokenSource; if !parser_errors.is_empty() || token_source.current().kind != SyntaxKind::EOF { return Err(()); } diff --git a/crates/ra_syntax/src/parsing/reparsing.rs b/crates/ra_syntax/src/parsing/reparsing.rs index 6644ffca4..4149f856a 100644 --- a/crates/ra_syntax/src/parsing/reparsing.rs +++ b/crates/ra_syntax/src/parsing/reparsing.rs @@ -6,7 +6,7 @@ //! - otherwise, we search for the nearest `{}` block which contains the edit //! and try to parse only this block. -use ra_parser::Reparser; +use parser::Reparser; use text_edit::Indel; use crate::{ diff --git a/crates/ra_syntax/src/parsing/text_token_source.rs b/crates/ra_syntax/src/parsing/text_token_source.rs index 97aa3e795..df866dc2b 100644 --- a/crates/ra_syntax/src/parsing/text_token_source.rs +++ b/crates/ra_syntax/src/parsing/text_token_source.rs @@ -1,10 +1,10 @@ //! See `TextTokenSource` docs. -use ra_parser::TokenSource; +use parser::TokenSource; use crate::{parsing::lexer::Token, SyntaxKind::EOF, TextRange, TextSize}; -/// Implementation of `ra_parser::TokenSource` that takes tokens from source code text. +/// Implementation of `parser::TokenSource` that takes tokens from source code text. pub(crate) struct TextTokenSource<'t> { text: &'t str, /// token and its start position (non-whitespace/comment tokens) @@ -20,15 +20,15 @@ pub(crate) struct TextTokenSource<'t> { token_offset_pairs: Vec<(Token, TextSize)>, /// Current token and position - curr: (ra_parser::Token, usize), + curr: (parser::Token, usize), } impl<'t> TokenSource for TextTokenSource<'t> { - fn current(&self) -> ra_parser::Token { + fn current(&self) -> parser::Token { self.curr.0 } - fn lookahead_nth(&self, n: usize) -> ra_parser::Token { + fn lookahead_nth(&self, n: usize) -> parser::Token { mk_token(self.curr.1 + n, &self.token_offset_pairs) } @@ -49,7 +49,7 @@ impl<'t> TokenSource for TextTokenSource<'t> { } } -fn mk_token(pos: usize, token_offset_pairs: &[(Token, TextSize)]) -> ra_parser::Token { +fn mk_token(pos: usize, token_offset_pairs: &[(Token, TextSize)]) -> parser::Token { let (kind, is_jointed_to_next) = match token_offset_pairs.get(pos) { Some((token, offset)) => ( token.kind, @@ -60,7 +60,7 @@ fn mk_token(pos: usize, token_offset_pairs: &[(Token, TextSize)]) -> ra_parser:: ), None => (EOF, false), }; - ra_parser::Token { kind, is_jointed_to_next } + parser::Token { kind, is_jointed_to_next } } impl<'t> TextTokenSource<'t> { diff --git a/crates/ra_syntax/src/parsing/text_tree_sink.rs b/crates/ra_syntax/src/parsing/text_tree_sink.rs index 6d1828d20..c1b5f246d 100644 --- a/crates/ra_syntax/src/parsing/text_tree_sink.rs +++ b/crates/ra_syntax/src/parsing/text_tree_sink.rs @@ -2,7 +2,7 @@ use std::mem; -use ra_parser::{ParseError, TreeSink}; +use parser::{ParseError, TreeSink}; use crate::{ parsing::Token, diff --git a/crates/ra_syntax/src/syntax_node.rs b/crates/ra_syntax/src/syntax_node.rs index a7dbdba7b..b2abcbfbb 100644 --- a/crates/ra_syntax/src/syntax_node.rs +++ b/crates/ra_syntax/src/syntax_node.rs @@ -71,7 +71,7 @@ impl SyntaxTreeBuilder { self.inner.finish_node() } - pub fn error(&mut self, error: ra_parser::ParseError, text_pos: TextSize) { + pub fn error(&mut self, error: parser::ParseError, text_pos: TextSize) { self.errors.push(SyntaxError::new_at_offset(*error.0, text_pos)) } } -- cgit v1.2.3