From a6224f36200c768d49b6450204fd95edaa559b50 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 18 Jul 2019 22:29:20 +0300 Subject: make Parse generic --- crates/ra_db/src/lib.rs | 6 +-- .../src/completion/completion_context.rs | 4 +- crates/ra_ide_api/src/status.rs | 6 +-- crates/ra_ide_api/src/symbol_index.rs | 4 +- crates/ra_syntax/src/lib.rs | 47 +++++++++++++++------- 5 files changed, 44 insertions(+), 23 deletions(-) diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index 11e18a03d..b82d1bda0 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs @@ -5,7 +5,7 @@ mod input; use std::{panic, sync::Arc}; use ra_prof::profile; -use ra_syntax::{Parse, SourceFile, TextRange, TextUnit}; +use ra_syntax::{ast, Parse, SourceFile, TextRange, TextUnit}; use relative_path::RelativePathBuf; pub use crate::{ @@ -74,7 +74,7 @@ pub trait SourceDatabase: CheckCanceled + std::fmt::Debug { fn file_text(&self, file_id: FileId) -> Arc; // Parses the file into the syntax tree. #[salsa::invoke(parse_query)] - fn parse(&self, file_id: FileId) -> Parse; + fn parse(&self, file_id: FileId) -> Parse; /// Path to a file, relative to the root of its source root. #[salsa::input] fn file_relative_path(&self, file_id: FileId) -> RelativePathBuf; @@ -98,7 +98,7 @@ fn source_root_crates(db: &impl SourceDatabase, id: SourceRootId) -> Arc Parse { +fn parse_query(db: &impl SourceDatabase, file_id: FileId) -> Parse { let _p = profile("parse_query"); let text = db.file_text(file_id); SourceFile::parse(&*text) diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs index f6584cdd6..4aa84751f 100644 --- a/crates/ra_ide_api/src/completion/completion_context.rs +++ b/crates/ra_ide_api/src/completion/completion_context.rs @@ -43,7 +43,7 @@ pub(crate) struct CompletionContext<'a> { impl<'a> CompletionContext<'a> { pub(super) fn new( db: &'a db::RootDatabase, - original_parse: &'a Parse, + original_parse: &'a Parse, position: FilePosition, ) -> Option> { let module = source_binder::module_from_position(db, position); @@ -83,7 +83,7 @@ impl<'a> CompletionContext<'a> { } } - fn fill(&mut self, original_parse: &'a Parse, offset: TextUnit) { + fn fill(&mut self, original_parse: &'a Parse, offset: TextUnit) { // Insert a fake ident to get a valid parse tree. We will use this file // to determine context, though the original_file will be used for // actual completion. diff --git a/crates/ra_ide_api/src/status.rs b/crates/ra_ide_api/src/status.rs index ce27f5ae2..d71c89b43 100644 --- a/crates/ra_ide_api/src/status.rs +++ b/crates/ra_ide_api/src/status.rs @@ -9,7 +9,7 @@ use ra_db::{ FileTextQuery, SourceRootId, }; use ra_prof::{memory_usage, Bytes}; -use ra_syntax::{AstNode, Parse, SyntaxNode, TreeArc}; +use ra_syntax::{ast, AstNode, Parse, SyntaxNode, TreeArc}; use crate::{ db::RootDatabase, @@ -79,10 +79,10 @@ impl fmt::Display for SyntaxTreeStats { } } -impl FromIterator> for SyntaxTreeStats { +impl FromIterator>> for SyntaxTreeStats { fn from_iter(iter: T) -> SyntaxTreeStats where - T: IntoIterator>, + T: IntoIterator>>, { let mut res = SyntaxTreeStats::default(); for entry in iter { diff --git a/crates/ra_ide_api/src/symbol_index.rs b/crates/ra_ide_api/src/symbol_index.rs index 1f2ba954e..9b3a45319 100644 --- a/crates/ra_ide_api/src/symbol_index.rs +++ b/crates/ra_ide_api/src/symbol_index.rs @@ -169,7 +169,9 @@ impl SymbolIndex { self.map.as_fst().size() + self.symbols.len() * mem::size_of::() } - pub(crate) fn for_files(files: impl ParallelIterator) -> SymbolIndex { + pub(crate) fn for_files( + files: impl ParallelIterator)>, + ) -> SymbolIndex { let symbols = files .flat_map(|(file_id, file)| source_file_to_file_symbols(file.tree(), file_id)) .collect::>(); diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index 0fa2fe382..2eb3fcd57 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs @@ -35,7 +35,7 @@ use std::{fmt::Write, sync::Arc}; use ra_text_edit::AtomTextEdit; -use crate::syntax_node::GreenNode; +use crate::syntax_node::{GreenNode, SyntaxNodeWrapper}; pub use crate::{ ast::{AstNode, AstToken}, @@ -57,14 +57,24 @@ pub use rowan::{SmolStr, TextRange, TextUnit}; /// /// Note that we always produce a syntax tree, even for completely invalid /// files. -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct Parse { - tree: TreeArc, +#[derive(Debug, PartialEq, Eq)] +pub struct Parse { + tree: TreeArc, errors: Arc>, } -impl Parse { - pub fn tree(&self) -> &SourceFile { +impl Clone for Parse { + fn clone(&self) -> Parse { + Parse { tree: self.tree.clone(), errors: self.errors.clone() } + } +} + +impl Parse { + fn new(tree: TreeArc, errors: Vec) -> Parse { + Parse { tree, errors: Arc::new(errors) } + } + + pub fn tree(&self) -> &T { &*self.tree } @@ -72,18 +82,16 @@ impl Parse { &*self.errors } - pub fn ok(self) -> Result, Arc>> { + pub fn ok(self) -> Result, Arc>> { if self.errors.is_empty() { Ok(self.tree) } else { Err(self.errors) } } +} - pub fn reparse(&self, edit: &AtomTextEdit) -> Parse { - self.incremental_reparse(edit).unwrap_or_else(|| self.full_reparse(edit)) - } - +impl Parse { pub fn debug_dump(&self) -> String { let mut buf = self.tree.syntax().debug_dump(); for err in self.errors.iter() { @@ -92,7 +100,11 @@ impl Parse { buf } - fn incremental_reparse(&self, edit: &AtomTextEdit) -> Option { + pub fn reparse(&self, edit: &AtomTextEdit) -> Parse { + self.incremental_reparse(edit).unwrap_or_else(|| self.full_reparse(edit)) + } + + fn incremental_reparse(&self, edit: &AtomTextEdit) -> Option> { // FIXME: validation errors are not handled here parsing::incremental_reparse(self.tree.syntax(), edit, self.errors.to_vec()).map( |(green_node, errors, _reparsed_range)| Parse { @@ -102,12 +114,19 @@ impl Parse { ) } - fn full_reparse(&self, edit: &AtomTextEdit) -> Parse { + fn full_reparse(&self, edit: &AtomTextEdit) -> Parse { let text = edit.apply(self.tree.syntax().text().to_string()); SourceFile::parse(&text) } } +impl Parse { + pub fn cast(self) -> Option> { + let node = T::cast(&self.tree)?; + Some(Parse { tree: node.to_owned(), errors: self.errors }) + } +} + /// `SourceFile` represents a parse tree for a single Rust file. pub use crate::ast::SourceFile; @@ -121,7 +140,7 @@ impl SourceFile { TreeArc::cast(root) } - pub fn parse(text: &str) -> Parse { + pub fn parse(text: &str) -> Parse { let (green, mut errors) = parsing::parse_text(text); let tree = SourceFile::new(green); errors.extend(validation::validate(&tree)); -- cgit v1.2.3 From df33e7685bdb0f63bf6aa809b9046708d563a1a7 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 18 Jul 2019 23:19:04 +0300 Subject: use Parse in mbe --- crates/ra_hir/src/db.rs | 4 +-- crates/ra_hir/src/ids.rs | 14 +++++----- crates/ra_ide_api/src/status.rs | 8 +++--- crates/ra_mbe/src/syntax_bridge.rs | 52 ++++++++++++++++--------------------- crates/ra_mbe/src/tests.rs | 30 ++++++++++----------- crates/ra_syntax/src/lib.rs | 12 ++++++--- crates/ra_syntax/src/syntax_node.rs | 7 ++--- 7 files changed, 64 insertions(+), 63 deletions(-) diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index 040c782e6..da9f3e32d 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use parking_lot::Mutex; use ra_db::{salsa, SourceDatabase}; -use ra_syntax::{ast, SmolStr, SyntaxNode, TreeArc}; +use ra_syntax::{ast, Parse, SmolStr, SyntaxNode, TreeArc}; use crate::{ adt::{EnumData, StructData}, @@ -69,7 +69,7 @@ pub trait AstDatabase: InternDatabase { fn parse_or_expand(&self, file_id: HirFileId) -> Option>; #[salsa::invoke(crate::ids::HirFileId::parse_macro_query)] - fn parse_macro(&self, macro_file: ids::MacroFile) -> Option>; + fn parse_macro(&self, macro_file: ids::MacroFile) -> Option>; #[salsa::invoke(crate::ids::macro_def_query)] fn macro_def(&self, macro_id: MacroDefId) -> Option>; diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index 80e9cccd6..83f5c3f39 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs @@ -6,7 +6,7 @@ use std::{ use mbe::MacroRules; use ra_db::{salsa, FileId}; use ra_prof::profile; -use ra_syntax::{ast, AstNode, SyntaxNode, TreeArc}; +use ra_syntax::{ast, AstNode, Parse, SyntaxNode, TreeArc}; use crate::{AstDatabase, AstId, DefDatabase, FileAstId, InternDatabase, Module, Source}; @@ -61,14 +61,16 @@ impl HirFileId { ) -> Option> { match file_id.0 { HirFileIdRepr::File(file_id) => Some(db.parse(file_id).tree().syntax().to_owned()), - HirFileIdRepr::Macro(macro_file) => db.parse_macro(macro_file), + HirFileIdRepr::Macro(macro_file) => { + db.parse_macro(macro_file).map(|it| it.tree().to_owned()) + } } } pub(crate) fn parse_macro_query( db: &impl AstDatabase, macro_file: MacroFile, - ) -> Option> { + ) -> Option> { let _p = profile("parse_macro_query"); let macro_call_id = macro_file.macro_call_id; let tt = db @@ -85,10 +87,8 @@ impl HirFileId { }) .ok()?; match macro_file.macro_file_kind { - MacroFileKind::Items => Some(mbe::token_tree_to_ast_item_list(&tt).syntax().to_owned()), - MacroFileKind::Expr => { - mbe::token_tree_to_expr(&tt).ok().map(|it| it.syntax().to_owned()) - } + MacroFileKind::Items => Some(Parse::to_syntax(mbe::token_tree_to_ast_item_list(&tt))), + MacroFileKind::Expr => mbe::token_tree_to_expr(&tt).ok().map(Parse::to_syntax), } } } diff --git a/crates/ra_ide_api/src/status.rs b/crates/ra_ide_api/src/status.rs index d71c89b43..a31e15245 100644 --- a/crates/ra_ide_api/src/status.rs +++ b/crates/ra_ide_api/src/status.rs @@ -9,7 +9,7 @@ use ra_db::{ FileTextQuery, SourceRootId, }; use ra_prof::{memory_usage, Bytes}; -use ra_syntax::{ast, AstNode, Parse, SyntaxNode, TreeArc}; +use ra_syntax::{ast, AstNode, Parse, SyntaxNode}; use crate::{ db::RootDatabase, @@ -96,15 +96,15 @@ impl FromIterator>> for SyntaxTreeStat } } -impl FromIterator>>> for SyntaxTreeStats { +impl FromIterator>>> for SyntaxTreeStats { fn from_iter(iter: T) -> SyntaxTreeStats where - T: IntoIterator>>>, + T: IntoIterator>>>, { let mut res = SyntaxTreeStats::default(); for entry in iter { res.total += 1; - if let Some(tree) = entry.value.and_then(|it| it) { + if let Some(tree) = entry.value.and_then(|it| it).map(|it| it.tree().to_owned()) { res.retained += 1; res.retained_size += tree.memory_size_of_subtree(); } diff --git a/crates/ra_mbe/src/syntax_bridge.rs b/crates/ra_mbe/src/syntax_bridge.rs index 7560d215a..bfc351f81 100644 --- a/crates/ra_mbe/src/syntax_bridge.rs +++ b/crates/ra_mbe/src/syntax_bridge.rs @@ -2,8 +2,8 @@ use crate::subtree_source::SubtreeTokenSource; use crate::ExpandError; use ra_parser::{ParseError, TreeSink}; use ra_syntax::{ - ast, AstNode, SmolStr, SyntaxElement, SyntaxKind, SyntaxKind::*, SyntaxNode, SyntaxTreeBuilder, - TextRange, TextUnit, TreeArc, T, + ast, AstNode, Parse, SmolStr, SyntaxElement, SyntaxKind, SyntaxKind::*, SyntaxNode, + SyntaxTreeBuilder, TextRange, TextUnit, T, }; use tt::buffer::{Cursor, TokenBuffer}; @@ -45,7 +45,7 @@ pub fn syntax_node_to_token_tree(node: &SyntaxNode) -> Option<(tt::Subtree, Toke // // -fn token_tree_to_syntax_node(tt: &tt::Subtree, f: F) -> Result, ExpandError> +fn token_tree_to_syntax_node(tt: &tt::Subtree, f: F) -> Result, ExpandError> where F: Fn(&mut dyn ra_parser::TokenSource, &mut dyn ra_parser::TreeSink), { @@ -58,50 +58,44 @@ where return Err(ExpandError::ConversionError); } //FIXME: would be cool to report errors - let (tree, _errors) = tree_sink.inner.finish(); - Ok(tree) + let parse = tree_sink.inner.finish(); + Ok(parse) } /// Parses the token tree (result of macro expansion) to an expression -pub fn token_tree_to_expr(tt: &tt::Subtree) -> Result, ExpandError> { - let syntax = token_tree_to_syntax_node(tt, ra_parser::parse_expr)?; - ast::Expr::cast(&syntax) - .map(|m| m.to_owned()) - .ok_or_else(|| crate::ExpandError::ConversionError) +pub fn token_tree_to_expr(tt: &tt::Subtree) -> Result, ExpandError> { + let parse = token_tree_to_syntax_node(tt, ra_parser::parse_expr)?; + parse.cast().ok_or_else(|| crate::ExpandError::ConversionError) } /// Parses the token tree (result of macro expansion) to a Pattern -pub fn token_tree_to_pat(tt: &tt::Subtree) -> Result, ExpandError> { - let syntax = token_tree_to_syntax_node(tt, ra_parser::parse_pat)?; - ast::Pat::cast(&syntax).map(|m| m.to_owned()).ok_or_else(|| ExpandError::ConversionError) +pub fn token_tree_to_pat(tt: &tt::Subtree) -> Result, ExpandError> { + let parse = token_tree_to_syntax_node(tt, ra_parser::parse_pat)?; + parse.cast().ok_or_else(|| crate::ExpandError::ConversionError) } /// Parses the token tree (result of macro expansion) to a Type -pub fn token_tree_to_ty(tt: &tt::Subtree) -> Result, ExpandError> { - let syntax = token_tree_to_syntax_node(tt, ra_parser::parse_ty)?; - ast::TypeRef::cast(&syntax).map(|m| m.to_owned()).ok_or_else(|| ExpandError::ConversionError) +pub fn token_tree_to_ty(tt: &tt::Subtree) -> Result, ExpandError> { + let parse = token_tree_to_syntax_node(tt, ra_parser::parse_ty)?; + parse.cast().ok_or_else(|| crate::ExpandError::ConversionError) } /// Parses the token tree (result of macro expansion) as a sequence of stmts -pub fn token_tree_to_macro_stmts( - tt: &tt::Subtree, -) -> Result, ExpandError> { - let syntax = token_tree_to_syntax_node(tt, ra_parser::parse_macro_stmts)?; - ast::MacroStmts::cast(&syntax).map(|m| m.to_owned()).ok_or_else(|| ExpandError::ConversionError) +pub fn token_tree_to_macro_stmts(tt: &tt::Subtree) -> Result, ExpandError> { + let parse = token_tree_to_syntax_node(tt, ra_parser::parse_macro_stmts)?; + parse.cast().ok_or_else(|| crate::ExpandError::ConversionError) } /// Parses the token tree (result of macro expansion) as a sequence of items -pub fn token_tree_to_macro_items( - tt: &tt::Subtree, -) -> Result, ExpandError> { - let syntax = token_tree_to_syntax_node(tt, ra_parser::parse_macro_items)?; - ast::MacroItems::cast(&syntax).map(|m| m.to_owned()).ok_or_else(|| ExpandError::ConversionError) +pub fn token_tree_to_macro_items(tt: &tt::Subtree) -> Result, ExpandError> { + let parse = token_tree_to_syntax_node(tt, ra_parser::parse_macro_items)?; + parse.cast().ok_or_else(|| crate::ExpandError::ConversionError) } /// Parses the token tree (result of macro expansion) as a sequence of items -pub fn token_tree_to_ast_item_list(tt: &tt::Subtree) -> TreeArc { - let syntax = token_tree_to_syntax_node(tt, ra_parser::parse).unwrap(); - ast::SourceFile::cast(&syntax).unwrap().to_owned() +pub fn token_tree_to_ast_item_list(tt: &tt::Subtree) -> Parse { + let parse = token_tree_to_syntax_node(tt, ra_parser::parse).unwrap(); + parse.cast().unwrap() } impl TokenMap { diff --git a/crates/ra_mbe/src/tests.rs b/crates/ra_mbe/src/tests.rs index 5a1494fee..419b2c099 100644 --- a/crates/ra_mbe/src/tests.rs +++ b/crates/ra_mbe/src/tests.rs @@ -72,7 +72,7 @@ pub(crate) fn expand_to_items( invocation: &str, ) -> ra_syntax::TreeArc { let expanded = expand(rules, invocation); - token_tree_to_macro_items(&expanded).unwrap() + token_tree_to_macro_items(&expanded).unwrap().tree().to_owned() } #[allow(unused)] @@ -81,7 +81,7 @@ pub(crate) fn expand_to_stmts( invocation: &str, ) -> ra_syntax::TreeArc { let expanded = expand(rules, invocation); - token_tree_to_macro_stmts(&expanded).unwrap() + token_tree_to_macro_stmts(&expanded).unwrap().tree().to_owned() } pub(crate) fn expand_to_expr( @@ -89,7 +89,7 @@ pub(crate) fn expand_to_expr( invocation: &str, ) -> ra_syntax::TreeArc { let expanded = expand(rules, invocation); - token_tree_to_expr(&expanded).unwrap() + token_tree_to_expr(&expanded).unwrap().tree().to_owned() } pub(crate) fn text_to_tokentree(text: &str) -> tt::Subtree { @@ -164,22 +164,22 @@ pub(crate) fn assert_expansion( let (expanded_tree, expected_tree) = match kind { MacroKind::Items => { - let expanded_tree = token_tree_to_macro_items(&expanded); - let expected_tree = token_tree_to_macro_items(&expected); + let expanded_tree = token_tree_to_macro_items(&expanded).unwrap().tree().to_owned(); + let expected_tree = token_tree_to_macro_items(&expected).unwrap().tree().to_owned(); ( - debug_dump_ignore_spaces(expanded_tree.unwrap().syntax()).trim().to_string(), - debug_dump_ignore_spaces(expected_tree.unwrap().syntax()).trim().to_string(), + debug_dump_ignore_spaces(expanded_tree.syntax()).trim().to_string(), + debug_dump_ignore_spaces(expected_tree.syntax()).trim().to_string(), ) } MacroKind::Stmts => { - let expanded_tree = token_tree_to_macro_stmts(&expanded); - let expected_tree = token_tree_to_macro_stmts(&expected); + let expanded_tree = token_tree_to_macro_stmts(&expanded).unwrap().tree().to_owned(); + let expected_tree = token_tree_to_macro_stmts(&expected).unwrap().tree().to_owned(); ( - debug_dump_ignore_spaces(expanded_tree.unwrap().syntax()).trim().to_string(), - debug_dump_ignore_spaces(expected_tree.unwrap().syntax()).trim().to_string(), + debug_dump_ignore_spaces(expanded_tree.syntax()).trim().to_string(), + debug_dump_ignore_spaces(expected_tree.syntax()).trim().to_string(), ) } }; @@ -419,9 +419,9 @@ fn test_expand_to_item_list() { ", ); let expansion = expand(&rules, "structs!(Foo, Bar);"); - let tree = token_tree_to_macro_items(&expansion); + let tree = token_tree_to_macro_items(&expansion).unwrap().tree().to_owned(); assert_eq!( - tree.unwrap().syntax().debug_dump().trim(), + tree.syntax().debug_dump().trim(), r#" MACRO_ITEMS@[0; 40) STRUCT_DEF@[0; 20) @@ -537,10 +537,10 @@ fn test_tt_to_stmts() { ); let expanded = expand(&rules, "foo!{}"); - let stmts = token_tree_to_macro_stmts(&expanded); + let stmts = token_tree_to_macro_stmts(&expanded).unwrap().tree().to_owned(); assert_eq!( - stmts.unwrap().syntax().debug_dump().trim(), + stmts.syntax().debug_dump().trim(), r#"MACRO_STMTS@[0; 15) LET_STMT@[0; 7) LET_KW@[0; 3) "let" diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index 2eb3fcd57..534c206a6 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs @@ -35,7 +35,7 @@ use std::{fmt::Write, sync::Arc}; use ra_text_edit::AtomTextEdit; -use crate::syntax_node::{GreenNode, SyntaxNodeWrapper}; +use crate::syntax_node::GreenNode; pub use crate::{ ast::{AstNode, AstToken}, @@ -43,8 +43,8 @@ pub use crate::{ ptr::{AstPtr, SyntaxNodePtr}, syntax_error::{Location, SyntaxError, SyntaxErrorKind}, syntax_node::{ - Direction, InsertPosition, SyntaxElement, SyntaxNode, SyntaxToken, SyntaxTreeBuilder, - TreeArc, WalkEvent, + Direction, InsertPosition, SyntaxElement, SyntaxNode, SyntaxNodeWrapper, SyntaxToken, + SyntaxTreeBuilder, TreeArc, WalkEvent, }, syntax_text::SyntaxText, }; @@ -91,6 +91,12 @@ impl Parse { } } +impl Parse { + pub fn to_syntax(this: Self) -> Parse { + Parse { tree: this.tree().syntax().to_owned(), errors: this.errors } + } +} + impl Parse { pub fn debug_dump(&self) -> String { let mut buf = self.tree.syntax().debug_dump(); diff --git a/crates/ra_syntax/src/syntax_node.rs b/crates/ra_syntax/src/syntax_node.rs index a1f9a59b6..e57813a94 100644 --- a/crates/ra_syntax/src/syntax_node.rs +++ b/crates/ra_syntax/src/syntax_node.rs @@ -18,7 +18,8 @@ use rowan::{GreenNodeBuilder, TransparentNewType}; use crate::{ syntax_error::{SyntaxError, SyntaxErrorKind}, - AstNode, SmolStr, SourceFile, SyntaxKind, SyntaxNodePtr, SyntaxText, TextRange, TextUnit, + AstNode, Parse, SmolStr, SourceFile, SyntaxKind, SyntaxNodePtr, SyntaxText, TextRange, + TextUnit, }; pub use rowan::WalkEvent; @@ -594,13 +595,13 @@ impl SyntaxTreeBuilder { (green, self.errors) } - pub fn finish(self) -> (TreeArc, Vec) { + pub fn finish(self) -> Parse { let (green, errors) = self.finish_raw(); let node = SyntaxNode::new(green); if cfg!(debug_assertions) { crate::validation::validate_block_structure(&node); } - (node, errors) + Parse::new(node, errors) } pub fn token(&mut self, kind: SyntaxKind, text: SmolStr) { -- cgit v1.2.3