mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
incremental reparse
This commit is contained in:
parent
5211e7d977
commit
c3e5987c43
5 changed files with 104 additions and 13 deletions
|
@ -2,7 +2,6 @@ mod event;
|
|||
mod input;
|
||||
|
||||
use {
|
||||
grammar,
|
||||
lexer::Token,
|
||||
parser_api::Parser,
|
||||
parser_impl::{
|
||||
|
@ -27,12 +26,16 @@ pub(crate) trait Sink<'a> {
|
|||
}
|
||||
|
||||
/// Parse a sequence of tokens into the representative node tree
|
||||
pub(crate) fn parse<'a, S: Sink<'a>>(text: &'a str, tokens: &[Token]) -> S::Tree {
|
||||
pub(crate) fn parse_with<'a, S: Sink<'a>>(
|
||||
text: &'a str,
|
||||
tokens: &[Token],
|
||||
parser: fn(&mut Parser),
|
||||
) -> S::Tree {
|
||||
let events = {
|
||||
let input = input::ParserInput::new(text, tokens);
|
||||
let parser_impl = ParserImpl::new(&input);
|
||||
let mut parser_api = Parser(parser_impl);
|
||||
grammar::file(&mut parser_api);
|
||||
parser(&mut parser_api);
|
||||
parser_api.0.into_events()
|
||||
};
|
||||
let mut sink = S::new(text);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue