@@ -35,7 +35,7 @@ impl MarkerEventContainer for LuaDocParser<'_, '_> {
35
35
}
36
36
}
37
37
38
- impl LuaDocParser < ' _ , ' _ > {
38
+ impl < ' b > LuaDocParser < ' _ , ' b > {
39
39
pub fn parse ( lua_parser : & mut LuaParser < ' _ > , tokens : & [ LuaTokenData ] ) {
40
40
let lexer = LuaDocLexer :: new ( lua_parser. origin_text ( ) ) ;
41
41
@@ -74,9 +74,7 @@ impl LuaDocParser<'_, '_> {
74
74
fn calc_next_current_token ( & mut self ) {
75
75
let token = self . lex_token ( ) ;
76
76
self . current_token = token. kind ;
77
- if !token. range . is_empty ( ) {
78
- self . current_token_range = token. range ;
79
- }
77
+ self . current_token_range = token. range ;
80
78
81
79
if self . current_token == LuaTokenKind :: TkEof {
82
80
return ;
@@ -141,7 +139,10 @@ impl LuaDocParser<'_, '_> {
141
139
self . origin_token_index + 1
142
140
} ;
143
141
if next_origin_index >= self . tokens . len ( ) {
144
- return LuaTokenData :: new ( LuaTokenKind :: TkEof , SourceRange :: EMPTY ) ;
142
+ return LuaTokenData :: new (
143
+ LuaTokenKind :: TkEof ,
144
+ SourceRange :: new ( self . current_token_range . end_offset ( ) , 0 ) ,
145
+ ) ;
145
146
}
146
147
147
148
let next_origin_token = self . tokens [ next_origin_index] ;
@@ -174,10 +175,13 @@ impl LuaDocParser<'_, '_> {
174
175
self . current_token_range
175
176
}
176
177
177
- pub fn current_token_text ( & self ) -> & str {
178
- let source_text = self . lua_parser . origin_text ( ) ;
178
+ pub fn current_token_text ( & self ) -> & ' b str {
179
179
let range = self . current_token_range ;
180
- & source_text[ range. start_offset ..range. end_offset ( ) ]
180
+ & self . origin_text ( ) [ range. start_offset ..range. end_offset ( ) ]
181
+ }
182
+
183
+ pub fn origin_text ( & self ) -> & ' b str {
184
+ self . lua_parser . origin_text ( )
181
185
}
182
186
183
187
pub fn set_state ( & mut self , state : LuaDocLexerState ) {
0 commit comments