mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 11:59:49 +00:00
internal: Add SyntaxFactory
to ease generating nodes with syntax mappings
This commit is contained in:
parent
af9a658864
commit
05b48e4005
5 changed files with 186 additions and 101 deletions
|
@ -7,8 +7,6 @@ use rustc_hash::FxHashMap;
|
|||
|
||||
use crate::{SyntaxElement, SyntaxNode};
|
||||
|
||||
use super::SyntaxEditor;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct SyntaxMapping {
|
||||
// important information to keep track of:
|
||||
|
@ -209,7 +207,7 @@ impl SyntaxMapping {
|
|||
Some(output)
|
||||
}
|
||||
|
||||
fn add_mapping(&mut self, syntax_mapping: SyntaxMappingBuilder) {
|
||||
pub fn add_mapping(&mut self, syntax_mapping: SyntaxMappingBuilder) {
|
||||
let SyntaxMappingBuilder { parent_node, node_mappings } = syntax_mapping;
|
||||
|
||||
let parent_entry: u32 = self.entry_parents.len().try_into().unwrap();
|
||||
|
@ -257,8 +255,8 @@ impl SyntaxMappingBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn finish(self, editor: &mut SyntaxEditor) {
|
||||
editor.mappings.add_mapping(self);
|
||||
pub fn finish(self, mappings: &mut SyntaxMapping) {
|
||||
mappings.add_mapping(self);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue