aboutsummaryrefslogtreecommitdiff
path: root/src/tree
diff options
context:
space:
mode:
Diffstat (limited to 'src/tree')
-rw-r--r--src/tree/file_builder.rs8
-rw-r--r--src/tree/mod.rs15
2 files changed, 16 insertions, 7 deletions
diff --git a/src/tree/file_builder.rs b/src/tree/file_builder.rs
index 37bd5b2c8..35702ddd7 100644
--- a/src/tree/file_builder.rs
+++ b/src/tree/file_builder.rs
@@ -48,7 +48,9 @@ impl Sink for FileBuilder {
48 } 48 }
49 49
50 fn finish_internal(&mut self) { 50 fn finish_internal(&mut self) {
51 let (id, _) = self.in_progress.pop().unwrap(); 51 let (id, _) = self.in_progress.pop().expect(
52 "trying to complete a node, but there are no in-progress nodes"
53 );
52 if !self.in_progress.is_empty() { 54 if !self.in_progress.is_empty() {
53 self.add_len(id); 55 self.add_len(id);
54 } 56 }
@@ -77,8 +79,8 @@ impl FileBuilder {
77 self.in_progress.iter().map(|&(idx, _)| self.nodes[idx].kind) 79 self.in_progress.iter().map(|&(idx, _)| self.nodes[idx].kind)
78 .collect::<Vec<_>>() 80 .collect::<Vec<_>>()
79 ); 81 );
80 assert!( 82 assert_eq!(
81 self.pos == (self.text.len() as u32).into(), 83 self.pos, (self.text.len() as u32).into(),
82 "nodes in FileBuilder do not cover the whole file" 84 "nodes in FileBuilder do not cover the whole file"
83 ); 85 );
84 File { 86 File {
diff --git a/src/tree/mod.rs b/src/tree/mod.rs
index d8f843737..3315b926e 100644
--- a/src/tree/mod.rs
+++ b/src/tree/mod.rs
@@ -10,17 +10,24 @@ pub use self::file_builder::{FileBuilder, Sink};
10#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] 10#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
11pub struct SyntaxKind(pub(crate) u32); 11pub struct SyntaxKind(pub(crate) u32);
12 12
13pub(crate) const EOF: SyntaxKind = SyntaxKind(10000); 13pub(crate) const EOF: SyntaxKind = SyntaxKind(!0);
14pub(crate) const EOF_INFO: SyntaxInfo = SyntaxInfo { 14pub(crate) const EOF_INFO: SyntaxInfo = SyntaxInfo {
15 name: "EOF" 15 name: "EOF"
16}; 16};
17 17
18pub(crate) const TOMBSTONE: SyntaxKind = SyntaxKind(!0 - 1);
19pub(crate) const TOMBSTONE_INFO: SyntaxInfo = SyntaxInfo {
20 name: "TOMBSTONE"
21};
22
23
18impl SyntaxKind { 24impl SyntaxKind {
19 fn info(self) -> &'static SyntaxInfo { 25 fn info(self) -> &'static SyntaxInfo {
20 if self == EOF { 26 match self {
21 return &EOF_INFO; 27 EOF => &EOF_INFO,
28 TOMBSTONE => &TOMBSTONE_INFO,
29 _ => syntax_info(self),
22 } 30 }
23 syntax_info(self)
24 } 31 }
25} 32}
26 33