Fix more bugs
This commit is contained in:
@@ -123,6 +123,11 @@ fn convert_tt(
|
||||
global_offset: TextUnit,
|
||||
tt: &SyntaxNode,
|
||||
) -> Option<tt::Subtree> {
|
||||
// This tree is empty
|
||||
if tt.first_child_or_token().is_none() {
|
||||
return Some(tt::Subtree { token_trees: vec![], delimiter: tt::Delimiter::None });
|
||||
}
|
||||
|
||||
let first_child = tt.first_child_or_token()?;
|
||||
let last_child = tt.last_child_or_token()?;
|
||||
let (delimiter, skip_first) = match (first_child.kind(), last_child.kind()) {
|
||||
@@ -233,7 +238,16 @@ impl<'a, Q: Querier> TreeSink for TtTreeSink<'a, Q> {
|
||||
self.text_pos += TextUnit::of_str(&self.buf);
|
||||
let text = SmolStr::new(self.buf.as_str());
|
||||
self.buf.clear();
|
||||
self.inner.token(kind, text)
|
||||
self.inner.token(kind, text);
|
||||
|
||||
// // Add a white space to token
|
||||
// let (last_kind, _, last_joint_to_next ) = self.src_querier.token(self.token_pos-n_tokens as usize);
|
||||
// if !last_joint_to_next && last_kind.is_punct() {
|
||||
// let (cur_kind, _, _ ) = self.src_querier.token(self.token_pos);
|
||||
// if cur_kind.is_punct() {
|
||||
// self.inner.token(WHITESPACE, " ".into());
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
fn start_node(&mut self, kind: SyntaxKind) {
|
||||
|
||||
Reference in New Issue
Block a user