@@ -35,7 +35,7 @@ impl MarkerEventContainer for LuaDocParser<'_, '_> {
3535 }
3636}
3737
38- impl LuaDocParser < ' _ , ' _ > {
38+ impl < ' b > LuaDocParser < ' _ , ' b > {
3939 pub fn parse ( lua_parser : & mut LuaParser < ' _ > , tokens : & [ LuaTokenData ] ) {
4040 let lexer = LuaDocLexer :: new ( lua_parser. origin_text ( ) ) ;
4141
@@ -74,9 +74,7 @@ impl LuaDocParser<'_, '_> {
7474 fn calc_next_current_token ( & mut self ) {
7575 let token = self . lex_token ( ) ;
7676 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 ;
8078
8179 if self . current_token == LuaTokenKind :: TkEof {
8280 return ;
@@ -141,7 +139,10 @@ impl LuaDocParser<'_, '_> {
141139 self . origin_token_index + 1
142140 } ;
143141 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+ ) ;
145146 }
146147
147148 let next_origin_token = self . tokens [ next_origin_index] ;
@@ -174,10 +175,13 @@ impl LuaDocParser<'_, '_> {
174175 self . current_token_range
175176 }
176177
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 {
179179 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 ( )
181185 }
182186
183187 pub fn set_state ( & mut self , state : LuaDocLexerState ) {
0 commit comments