Skip to content

Commit 4f12659

Browse files
committed
Revert legacy
1 parent dab35a0 commit 4f12659

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

crates/swc_ecma_lexer/src/lexer/comments_buffer.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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

3034
impl CommentsBufferTrait for CommentsBuffer {

crates/swc_ecma_lexer/src/lexer/state.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff 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());

0 commit comments

Comments
 (0)