11//! See [`Input`].
22
3+ use edition:: Edition ;
4+
35use crate :: SyntaxKind ;
46
57#[ allow( non_camel_case_types) ]
@@ -16,6 +18,7 @@ pub struct Input {
1618 kind : Vec < SyntaxKind > ,
1719 joint : Vec < bits > ,
1820 contextual_kind : Vec < SyntaxKind > ,
21+ edition : Vec < Edition > ,
1922}
2023
2124/// `pub` impl used by callers to create `Tokens`.
@@ -26,15 +29,16 @@ impl Input {
2629 kind : Vec :: with_capacity ( capacity) ,
2730 joint : Vec :: with_capacity ( capacity / size_of :: < bits > ( ) ) ,
2831 contextual_kind : Vec :: with_capacity ( capacity) ,
32+ edition : Vec :: with_capacity ( capacity) ,
2933 }
3034 }
3135 #[ inline]
32- pub fn push ( & mut self , kind : SyntaxKind ) {
33- self . push_impl ( kind, SyntaxKind :: EOF )
36+ pub fn push ( & mut self , kind : SyntaxKind , edition : Edition ) {
37+ self . push_impl ( kind, SyntaxKind :: EOF , edition )
3438 }
3539 #[ inline]
36- pub fn push_ident ( & mut self , contextual_kind : SyntaxKind ) {
37- self . push_impl ( SyntaxKind :: IDENT , contextual_kind)
40+ pub fn push_ident ( & mut self , contextual_kind : SyntaxKind , edition : Edition ) {
41+ self . push_impl ( SyntaxKind :: IDENT , contextual_kind, edition )
3842 }
3943 /// Sets jointness for the last token we've pushed.
4044 ///
@@ -59,13 +63,14 @@ impl Input {
5963 self . joint [ idx] |= 1 << b_idx;
6064 }
6165 #[ inline]
62- fn push_impl ( & mut self , kind : SyntaxKind , contextual_kind : SyntaxKind ) {
66+ fn push_impl ( & mut self , kind : SyntaxKind , contextual_kind : SyntaxKind , edition : Edition ) {
6367 let idx = self . len ( ) ;
6468 if idx. is_multiple_of ( bits:: BITS as usize ) {
6569 self . joint . push ( 0 ) ;
6670 }
6771 self . kind . push ( kind) ;
6872 self . contextual_kind . push ( contextual_kind) ;
73+ self . edition . push ( edition) ;
6974 }
7075}
7176
@@ -77,6 +82,9 @@ impl Input {
7782 pub ( crate ) fn contextual_kind ( & self , idx : usize ) -> SyntaxKind {
7883 self . contextual_kind . get ( idx) . copied ( ) . unwrap_or ( SyntaxKind :: EOF )
7984 }
85+ pub ( crate ) fn edition ( & self , idx : usize ) -> Edition {
86+ self . edition [ idx]
87+ }
8088 pub ( crate ) fn is_joint ( & self , n : usize ) -> bool {
8189 let ( idx, b_idx) = self . bit_index ( n) ;
8290 self . joint [ idx] & ( 1 << b_idx) != 0
0 commit comments