File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
crates/swc_ecma_lexer/src/lexer Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,10 @@ impl CommentsBuffer {
2525 pending_leading : OneDirectionalList :: new ( ) ,
2626 }
2727 }
28+
29+ pub fn take_pending_leading ( & mut self ) -> Rev < IntoIter < Comment > > {
30+ self . pending_leading . take_all ( )
31+ }
2832}
2933
3034impl CommentsBufferTrait for CommentsBuffer {
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ use crate::{
1111 input:: Tokens ,
1212 lexer:: {
1313 char:: CharExt ,
14- comments_buffer:: { BufferedCommentKind , CommentsBufferTrait } ,
14+ comments_buffer:: { BufferedComment , BufferedCommentKind , CommentsBufferTrait } ,
1515 state:: {
1616 State as StateTrait , TokenKind as TokenKindTrait , TokenType as TokenTypeTrait ,
1717 } ,
@@ -870,7 +870,13 @@ impl Iterator for Lexer<'_> {
870870 let span = self . span ( start) ;
871871 if !matches ! ( token, Token :: Eof ) {
872872 if let Some ( comments) = self . comments_buffer . as_mut ( ) {
873- comments. pending_to_comment ( BufferedCommentKind :: Leading , start) ;
873+ for comment in comments. take_pending_leading ( ) {
874+ comments. push_comment ( BufferedComment {
875+ kind : BufferedCommentKind :: Leading ,
876+ pos : start,
877+ comment,
878+ } ) ;
879+ }
874880 }
875881
876882 self . state . update ( start, token. kind ( ) ) ;
You can’t perform that action at this time.
0 commit comments