Skip to content

Commit 9396417

Browse files
committed
PR feedback and fix NewFalseExpression
1 parent c79c70c commit 9396417

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

internal/printer/factory.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func (f *NodeFactory) NewTrueExpression() *ast.Expression {
195195
}
196196

197197
func (f *NodeFactory) NewFalseExpression() *ast.Expression {
198-
return f.NewKeywordExpression(ast.KindTrueKeyword)
198+
return f.NewKeywordExpression(ast.KindFalseKeyword)
199199
}
200200

201201
//

internal/printer/printer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5171,7 +5171,7 @@ func (p *Printer) emitLeadingComments(pos int, elided bool) bool {
51715171
}
51725172

51735173
var comments []ast.CommentRange
5174-
for comment := range scanner.GetLeadingCommentRanges(p.emitContext.Factory, p.currentSourceFile.Text(), pos) {
5174+
for comment := range scanner.GetLeadingCommentRanges(p.emitContext.Factory.AsNodeFactory(), p.currentSourceFile.Text(), pos) {
51755175
if p.shouldWriteComment(comment) && p.shouldEmitCommentIfTripleSlash(comment, tripleSlash) {
51765176
comments = append(comments, comment)
51775177
}
@@ -5210,7 +5210,7 @@ func (p *Printer) emitTrailingComments(pos int, commentSeparator commentSeparato
52105210
}
52115211

52125212
var comments []ast.CommentRange
5213-
for comment := range scanner.GetTrailingCommentRanges(p.emitContext.Factory, p.currentSourceFile.Text(), pos) {
5213+
for comment := range scanner.GetTrailingCommentRanges(p.emitContext.Factory.AsNodeFactory(), p.currentSourceFile.Text(), pos) {
52145214
if p.shouldWriteComment(comment) {
52155215
comments = append(comments, comment)
52165216
}
@@ -5245,15 +5245,15 @@ func (p *Printer) emitDetachedComments(textRange core.TextRange) (result detache
52455245
//
52465246
// var x = 10;
52475247
if textRange.Pos() == 0 {
5248-
for comment := range scanner.GetLeadingCommentRanges(p.emitContext.Factory, text, textRange.Pos()) {
5248+
for comment := range scanner.GetLeadingCommentRanges(p.emitContext.Factory.AsNodeFactory(), text, textRange.Pos()) {
52495249
if isPinnedComment(text, comment) {
52505250
leadingComments = append(leadingComments, comment)
52515251
}
52525252
}
52535253
}
52545254
} else {
52555255
// removeComments is false, just get detached as normal and bypass the process to filter comment
5256-
leadingComments = slices.Collect(scanner.GetLeadingCommentRanges(p.emitContext.Factory, text, textRange.Pos()))
5256+
leadingComments = slices.Collect(scanner.GetLeadingCommentRanges(p.emitContext.Factory.AsNodeFactory(), text, textRange.Pos()))
52575257
}
52585258

52595259
if len(leadingComments) > 0 {

internal/scanner/scanner.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2341,11 +2341,11 @@ func ComputePositionOfLineAndCharacter(lineStarts []core.TextPos, line int, char
23412341
return res
23422342
}
23432343

2344-
func GetLeadingCommentRanges(f ast.NodeFactoryCoercible, text string, pos int) iter.Seq[ast.CommentRange] {
2344+
func GetLeadingCommentRanges(f *ast.NodeFactory, text string, pos int) iter.Seq[ast.CommentRange] {
23452345
return iterateCommentRanges(f, text, pos, false)
23462346
}
23472347

2348-
func GetTrailingCommentRanges(f ast.NodeFactoryCoercible, text string, pos int) iter.Seq[ast.CommentRange] {
2348+
func GetTrailingCommentRanges(f *ast.NodeFactory, text string, pos int) iter.Seq[ast.CommentRange] {
23492349
return iterateCommentRanges(f, text, pos, true)
23502350
}
23512351

@@ -2355,8 +2355,7 @@ Single-line comment ranges include the leading double-slash characters but not t
23552355
line break. Multi-line comment ranges include the leading slash-asterisk and trailing
23562356
asterisk-slash characters.
23572357
*/
2358-
func iterateCommentRanges(fc ast.NodeFactoryCoercible, text string, pos int, trailing bool) iter.Seq[ast.CommentRange] {
2359-
f := fc.AsNodeFactory()
2358+
func iterateCommentRanges(f *ast.NodeFactory, text string, pos int, trailing bool) iter.Seq[ast.CommentRange] {
23602359
return func(yield func(ast.CommentRange) bool) {
23612360
var pendingPos int
23622361
var pendingEnd int

0 commit comments

Comments
 (0)