Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/checker/grammarchecks.go
Original file line number Diff line number Diff line change
Expand Up @@ -814,8 +814,8 @@ func (c *Checker) checkGrammarArrowFunction(node *ast.Node, file *ast.SourceFile
}

equalsGreaterThanToken := arrowFunc.EqualsGreaterThanToken
startLine, _ := scanner.GetECMALineAndCharacterOfPosition(file, equalsGreaterThanToken.Pos())
endLine, _ := scanner.GetECMALineAndCharacterOfPosition(file, equalsGreaterThanToken.End())
startLine := scanner.GetECMALineOfPosition(file, equalsGreaterThanToken.Pos())
endLine := scanner.GetECMALineOfPosition(file, equalsGreaterThanToken.End())
return startLine != endLine && c.grammarErrorOnNode(equalsGreaterThanToken, diagnostics.Line_terminator_not_permitted_before_arrow)
}

Expand Down
2 changes: 1 addition & 1 deletion internal/compiler/program.go
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ func (p *Program) getDiagnosticsWithPrecedingDirectives(sourceFile *ast.SourceFi
// Build map of directives by line number
directivesByLine := make(map[int]ast.CommentDirective)
for _, directive := range sourceFile.CommentDirectives {
line, _ := scanner.GetECMALineAndCharacterOfPosition(sourceFile, directive.Loc.Pos())
line := scanner.GetECMALineOfPosition(sourceFile, directive.Loc.Pos())
directivesByLine[line] = directive
}
lineStarts := scanner.GetECMALineStarts(sourceFile)
Expand Down
4 changes: 2 additions & 2 deletions internal/diagnosticwriter/diagnosticwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func writeCodeSnippet(writer io.Writer, sourceFile *ast.SourceFile, start int, l
lastLineChar++ // When length is zero, squiggle the character right after the start position.
}

lastLineOfFile, _ := scanner.GetECMALineAndCharacterOfPosition(sourceFile, len(sourceFile.Text()))
lastLineOfFile := scanner.GetECMALineOfPosition(sourceFile, len(sourceFile.Text()))

hasMoreThanFiveLines := lastLine-firstLine >= 4
gutterWidth := len(strconv.Itoa(lastLine + 1))
Expand Down Expand Up @@ -357,7 +357,7 @@ func prettyPathForFileError(file *ast.SourceFile, fileErrors []*ast.Diagnostic,
if file == nil || len(fileErrors) == 0 {
return ""
}
line, _ := scanner.GetECMALineAndCharacterOfPosition(file, fileErrors[0].Loc().Pos())
line := scanner.GetECMALineOfPosition(file, fileErrors[0].Loc().Pos())
fileName := file.FileName()
if tspath.PathIsAbsolute(fileName) && tspath.PathIsAbsolute(formatOpts.CurrentDirectory) {
fileName = tspath.ConvertToRelativePath(file.FileName(), formatOpts.ComparePathsOptions)
Expand Down
2 changes: 1 addition & 1 deletion internal/format/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func FormatOnSemicolon(ctx context.Context, sourceFile *ast.SourceFile, position
}

func FormatOnEnter(ctx context.Context, sourceFile *ast.SourceFile, position int) []core.TextChange {
line, _ := scanner.GetECMALineAndCharacterOfPosition(sourceFile, position)
line := scanner.GetECMALineOfPosition(sourceFile, position)
if line == 0 {
return nil
}
Expand Down
24 changes: 14 additions & 10 deletions internal/format/indent.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func getIndentationForNodeWorker(
// }) looking at the relationship between the list and *first* list item.
var listIndentsChild bool
if firstListChild != nil {
listLine, _ := getStartLineAndCharacterForNode(firstListChild, sourceFile)
listLine := getStartLineForNode(firstListChild, sourceFile)
listIndentsChild = listLine > containingListOrParentStartLine
}
actualIndentation := getActualIndentationForListItem(current, sourceFile, options, listIndentsChild)
Expand Down Expand Up @@ -134,7 +134,7 @@ func isArgumentAndStartLineOverlapsExpressionBeingCalled(parent *ast.Node, child
return false
}
expressionOfCallExpressionEnd := parent.Expression().End()
expressionOfCallExpressionEndLine, _ := scanner.GetECMALineAndCharacterOfPosition(sourceFile, expressionOfCallExpressionEnd)
expressionOfCallExpressionEndLine := scanner.GetECMALineOfPosition(sourceFile, expressionOfCallExpressionEnd)
return expressionOfCallExpressionEndLine == childStartLine
}

Expand Down Expand Up @@ -188,7 +188,7 @@ func deriveActualIndentationFromList(list *ast.NodeList, index int, sourceFile *
continue
}
// skip list items that ends on the same line with the current list element
prevEndLine, _ := scanner.GetECMALineAndCharacterOfPosition(sourceFile, list.Nodes[i].End())
prevEndLine := scanner.GetECMALineOfPosition(sourceFile, list.Nodes[i].End())
if prevEndLine != line {
return findColumnForFirstNonWhitespaceCharacterInLine(line, char, sourceFile, options)
}
Expand Down Expand Up @@ -243,7 +243,7 @@ func childStartsOnTheSameLineWithElseInIfStatement(parent *ast.Node, child *ast.
if parent.Kind == ast.KindIfStatement && parent.AsIfStatement().ElseStatement == child {
elseKeyword := astnav.FindPrecedingToken(sourceFile, child.Pos())
debug.AssertIsDefined(elseKeyword)
elseKeywordStartLine, _ := getStartLineAndCharacterForNode(elseKeyword, sourceFile)
elseKeywordStartLine := getStartLineForNode(elseKeyword, sourceFile)
return elseKeywordStartLine == childStartLine
}
return false
Expand All @@ -253,6 +253,10 @@ func getStartLineAndCharacterForNode(n *ast.Node, sourceFile *ast.SourceFile) (l
return scanner.GetECMALineAndCharacterOfPosition(sourceFile, scanner.GetTokenPosOfNode(n, sourceFile, false))
}

func getStartLineForNode(n *ast.Node, sourceFile *ast.SourceFile) int {
return scanner.GetECMALineOfPosition(sourceFile, scanner.GetTokenPosOfNode(n, sourceFile, false))
}

func GetContainingList(node *ast.Node, sourceFile *ast.SourceFile) *ast.NodeList {
if node.Parent == nil {
return nil
Expand Down Expand Up @@ -442,8 +446,8 @@ func NodeWillIndentChild(settings *FormatCodeSettings, parent *ast.Node, child *
return rangeIsOnOneLine(child.Loc, sourceFile)
}
if parent.Kind == ast.KindBinaryExpression && sourceFile != nil && childKind == ast.KindJsxElement {
parentStartLine, _ := scanner.GetECMALineAndCharacterOfPosition(sourceFile, scanner.SkipTrivia(sourceFile.Text(), parent.Pos()))
childStartLine, _ := scanner.GetECMALineAndCharacterOfPosition(sourceFile, scanner.SkipTrivia(sourceFile.Text(), child.Pos()))
parentStartLine := scanner.GetECMALineOfPosition(sourceFile, scanner.SkipTrivia(sourceFile.Text(), parent.Pos()))
childStartLine := scanner.GetECMALineOfPosition(sourceFile, scanner.SkipTrivia(sourceFile.Text(), child.Pos()))
return parentStartLine != childStartLine
}
if parent.Kind != ast.KindBinaryExpression {
Expand Down Expand Up @@ -519,7 +523,7 @@ func NodeWillIndentChild(settings *FormatCodeSettings, parent *ast.Node, child *
// branch beginning on the line that the whenTrue branch ends.
func childIsUnindentedBranchOfConditionalExpression(parent *ast.Node, child *ast.Node, childStartLine int, sourceFile *ast.SourceFile) bool {
if parent.Kind == ast.KindConditionalExpression && (child == parent.AsConditionalExpression().WhenTrue || child == parent.AsConditionalExpression().WhenFalse) {
conditionEndLine, _ := scanner.GetECMALineAndCharacterOfPosition(sourceFile, parent.AsConditionalExpression().Condition.End())
conditionEndLine := scanner.GetECMALineOfPosition(sourceFile, parent.AsConditionalExpression().Condition.End())
if child == parent.AsConditionalExpression().WhenTrue {
return childStartLine == conditionEndLine
} else {
Expand All @@ -530,8 +534,8 @@ func childIsUnindentedBranchOfConditionalExpression(parent *ast.Node, child *ast
// ? 1 : ( L1: whenTrue indented because it's on a new line
// 0 L2: indented two stops, one because whenTrue was indented
// ); and one because of the parentheses spanning multiple lines
trueStartLine, _ := getStartLineAndCharacterForNode(parent.AsConditionalExpression().WhenTrue, sourceFile)
trueEndLine, _ := scanner.GetECMALineAndCharacterOfPosition(sourceFile, parent.AsConditionalExpression().WhenTrue.End())
trueStartLine := getStartLineForNode(parent.AsConditionalExpression().WhenTrue, sourceFile)
trueEndLine := scanner.GetECMALineOfPosition(sourceFile, parent.AsConditionalExpression().WhenTrue.End())
return conditionEndLine == trueStartLine && trueEndLine == childStartLine
}
}
Expand All @@ -553,7 +557,7 @@ func argumentStartsOnSameLineAsPreviousArgument(parent *ast.Node, child *ast.Nod
}

previousNode := parent.Arguments()[currentIndex-1]
lineOfPreviousNode, _ := scanner.GetECMALineAndCharacterOfPosition(sourceFile, previousNode.End())
lineOfPreviousNode := scanner.GetECMALineOfPosition(sourceFile, previousNode.End())
if childStartLine == lineOfPreviousNode {
return true
}
Expand Down
4 changes: 2 additions & 2 deletions internal/format/rulecontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,8 +584,8 @@ func isSemicolonDeletionContext(context *FormattingContext) bool {
nextTokenStart = scanner.GetTokenPosOfNode(nextRealToken, context.SourceFile, false)
}

startLine, _ := scanner.GetECMALineAndCharacterOfPosition(context.SourceFile, context.currentTokenSpan.Loc.Pos())
endLine, _ := scanner.GetECMALineAndCharacterOfPosition(context.SourceFile, nextTokenStart)
startLine := scanner.GetECMALineOfPosition(context.SourceFile, context.currentTokenSpan.Loc.Pos())
endLine := scanner.GetECMALineOfPosition(context.SourceFile, nextTokenStart)
if startLine == endLine {
return nextTokenKind == ast.KindCloseBraceToken || nextTokenKind == ast.KindEndOfFile
}
Expand Down
28 changes: 14 additions & 14 deletions internal/format/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func getOwnOrInheritedDelta(n *ast.Node, options *FormatCodeSettings, sourceFile
previousLine := -1
var child *ast.Node
for n != nil {
line, _ := scanner.GetECMALineAndCharacterOfPosition(sourceFile, withTokenStart(n, sourceFile).Pos())
line := scanner.GetECMALineOfPosition(sourceFile, withTokenStart(n, sourceFile).Pos())
if previousLine != -1 && line != previousLine {
break
}
Expand Down Expand Up @@ -242,10 +242,10 @@ func (w *formatSpanWorker) execute(s *formattingScanner) []core.TextChange {
w.formattingScanner.advance()

if w.formattingScanner.isOnToken() {
startLine, _ := scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, withTokenStart(w.enclosingNode, w.sourceFile).Pos())
startLine := scanner.GetECMALineOfPosition(w.sourceFile, withTokenStart(w.enclosingNode, w.sourceFile).Pos())
undecoratedStartLine := startLine
if ast.HasDecorators(w.enclosingNode) {
undecoratedStartLine, _ = scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, getNonDecoratorTokenPosOfNode(w.enclosingNode, w.sourceFile))
undecoratedStartLine = scanner.GetECMALineOfPosition(w.sourceFile, getNonDecoratorTokenPosOfNode(w.enclosingNode, w.sourceFile))
}

w.processNode(w.enclosingNode, w.enclosingNode, startLine, undecoratedStartLine, w.initialIndentation, w.delta)
Expand Down Expand Up @@ -305,7 +305,7 @@ func (w *formatSpanWorker) execute(s *formattingScanner) []core.TextChange {
if parent == nil {
parent = w.previousParent
}
line, _ := scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, tokenInfo.Loc.Pos())
line:= scanner.GetECMALineOfPosition(w.sourceFile, tokenInfo.Loc.Pos())
w.processPair(
tokenInfo,
line,
Expand Down Expand Up @@ -343,11 +343,11 @@ func (w *formatSpanWorker) processChildNode(
}

childStartPos := scanner.GetTokenPosOfNode(child, w.sourceFile, false)
childStartLine, _ := scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, childStartPos)
childStartLine := scanner.GetECMALineOfPosition(w.sourceFile, childStartPos)

undecoratedChildStartLine := childStartLine
if ast.HasDecorators(child) {
undecoratedChildStartLine, _ = scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, getNonDecoratorTokenPosOfNode(child, w.sourceFile))
undecoratedChildStartLine = scanner.GetECMALineOfPosition(w.sourceFile, getNonDecoratorTokenPosOfNode(child, w.sourceFile))
}

// if child is a list item - try to get its indentation, only if parent is within the original range.
Expand Down Expand Up @@ -457,7 +457,7 @@ func (w *formatSpanWorker) processChildNodes(
break
} else if tokenInfo.token.Kind == listStartToken {
// consume list start token
startLine, _ = scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, tokenInfo.token.Loc.Pos())
startLine = scanner.GetECMALineOfPosition(w.sourceFile, tokenInfo.token.Loc.Pos())

w.consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent, false)

Expand Down Expand Up @@ -578,7 +578,7 @@ func (w *formatSpanWorker) tryComputeIndentationForListItem(startPos int, endPos
return inheritedIndentation
}
} else {
startLine, _ := scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, startPos)
startLine := scanner.GetECMALineOfPosition(w.sourceFile, startPos)
startLinePosition := GetLineStartPositionForPosition(startPos, w.sourceFile)
column := FindFirstNonWhitespaceColumn(startLinePosition, startPos, w.sourceFile, w.formattingContext.Options)
if startLine != parentStartLine || startPos == column {
Expand Down Expand Up @@ -747,7 +747,7 @@ func (w *formatSpanWorker) processRange(r TextRangeWithKind, rangeStartLine int,
if !rangeHasError {
if w.previousRange == NewTextRangeWithKind(0, 0, 0) {
// trim whitespaces starting from the beginning of the span up to the current line
originalStartLine, _ := scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, w.originalRange.Pos())
originalStartLine := scanner.GetECMALineOfPosition(w.sourceFile, w.originalRange.Pos())
w.trimTrailingWhitespacesForLines(originalStartLine, rangeStartLine, NewTextRangeWithKind(0, 0, 0))
} else {
lineAction = w.processPair(r, rangeStartLine, parent, w.previousRange, w.previousRangeStartLine, w.previousParent, contextNode, dynamicIndentation)
Expand Down Expand Up @@ -797,8 +797,8 @@ func (w *formatSpanWorker) trimTrailingWhitespacesForRemainingRange(trivias []Te
}

func (w *formatSpanWorker) trimTrailingWitespacesForPositions(startPos int, endPos int, previousRange TextRangeWithKind) {
startLine, _ := scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, startPos)
endLine, _ := scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, endPos)
startLine := scanner.GetECMALineOfPosition(w.sourceFile, startPos)
endLine := scanner.GetECMALineOfPosition(w.sourceFile, endPos)

w.trimTrailingWhitespacesForLines(startLine, endLine+1, previousRange)
}
Expand Down Expand Up @@ -909,8 +909,8 @@ func (w *formatSpanWorker) indentTriviaItems(trivia []TextRangeWithKind, comment

func (w *formatSpanWorker) indentMultilineComment(commentRange core.TextRange, indentation int, firstLineIsIndented bool, indentFinalLine bool) {
// split comment in lines
startLine, _ := scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, commentRange.Pos())
endLine, _ := scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, commentRange.End())
startLine := scanner.GetECMALineOfPosition(w.sourceFile, commentRange.Pos())
endLine := scanner.GetECMALineOfPosition(w.sourceFile, commentRange.End())

if startLine == endLine {
if !firstLineIsIndented {
Expand Down Expand Up @@ -1033,7 +1033,7 @@ func (w *formatSpanWorker) consumeTokenAndAdvanceScanner(currentTokenInfo tokenI
if lineAction == LineActionNone {
// indent token only if end line of previous range does not match start line of the token
if savePreviousRange != NewTextRangeWithKind(0, 0, 0) {
prevEndLine, _ := scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, savePreviousRange.Loc.End())
prevEndLine := scanner.GetECMALineOfPosition(w.sourceFile, savePreviousRange.Loc.End())
indentToken = lastTriviaWasNewLine && tokenStartLine != prevEndLine
}
} else {
Expand Down
6 changes: 3 additions & 3 deletions internal/format/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
)

func rangeIsOnOneLine(node core.TextRange, file *ast.SourceFile) bool {
startLine, _ := scanner.GetECMALineAndCharacterOfPosition(file, node.Pos())
endLine, _ := scanner.GetECMALineAndCharacterOfPosition(file, node.End())
startLine := scanner.GetECMALineOfPosition(file, node.Pos())
endLine := scanner.GetECMALineOfPosition(file, node.End())
return startLine == endLine
}

Expand Down Expand Up @@ -77,7 +77,7 @@ func getCloseTokenForOpenToken(kind ast.Kind) ast.Kind {

func GetLineStartPositionForPosition(position int, sourceFile *ast.SourceFile) int {
lineStarts := scanner.GetECMALineStarts(sourceFile)
line, _ := scanner.GetECMALineAndCharacterOfPosition(sourceFile, position)
line := scanner.GetECMALineOfPosition(sourceFile, position)
return int(lineStarts[line])
}

Expand Down
6 changes: 3 additions & 3 deletions internal/ls/completions.go
Original file line number Diff line number Diff line change
Expand Up @@ -2524,7 +2524,7 @@ func boolToPtr(v bool) *bool {
}

func getLineOfPosition(file *ast.SourceFile, pos int) int {
line, _ := scanner.GetECMALineAndCharacterOfPosition(file, pos)
line := scanner.GetECMALineOfPosition(file, pos)
return line
}

Expand Down Expand Up @@ -3521,8 +3521,8 @@ func getContextualKeywords(file *ast.SourceFile, contextToken *ast.Node, positio
// Source: https://tc39.es/proposal-import-assertions/
if contextToken != nil {
parent := contextToken.Parent
tokenLine, _ := scanner.GetECMALineAndCharacterOfPosition(file, contextToken.End())
currentLine, _ := scanner.GetECMALineAndCharacterOfPosition(file, position)
tokenLine := scanner.GetECMALineOfPosition(file, contextToken.End())
currentLine := scanner.GetECMALineOfPosition(file, position)
if (ast.IsImportDeclaration(parent) ||
ast.IsExportDeclaration(parent) && parent.AsExportDeclaration().ModuleSpecifier != nil) &&
contextToken == parent.ModuleSpecifier() &&
Expand Down
4 changes: 2 additions & 2 deletions internal/ls/lsutil/asi.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func NodeIsASICandidate(node *ast.Node, file *ast.SourceFile) bool {
return true
}

startLine, _ := scanner.GetECMALineAndCharacterOfPosition(file, node.End())
endLine, _ := scanner.GetECMALineAndCharacterOfPosition(file, astnav.GetStartOfNode(nextToken, file, false /*includeJSDoc*/))
startLine := scanner.GetECMALineOfPosition(file, node.End())
endLine := scanner.GetECMALineOfPosition(file, astnav.GetStartOfNode(nextToken, file, false /*includeJSDoc*/))
return startLine != endLine
}
4 changes: 2 additions & 2 deletions internal/ls/lsutil/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ func ProbablyUsesSemicolons(file *ast.SourceFile) bool {
if lastToken != nil && lastToken.Kind == ast.KindSemicolonToken {
withSemicolon++
} else if lastToken != nil && lastToken.Kind != ast.KindCommaToken {
lastTokenLine, _ := scanner.GetECMALineAndCharacterOfPosition(
lastTokenLine := scanner.GetECMALineOfPosition(
file,
astnav.GetStartOfNode(lastToken, file, false /*includeJSDoc*/))
nextTokenLine, _ := scanner.GetECMALineAndCharacterOfPosition(
nextTokenLine := scanner.GetECMALineOfPosition(
file,
scanner.GetRangeOfTokenAtPosition(file, lastToken.End()).Pos())
// Avoid counting missing semicolon in single-line objects:
Expand Down
10 changes: 8 additions & 2 deletions internal/scanner/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -2337,8 +2337,8 @@ func getErrorRangeForArrowFunction(sourceFile *ast.SourceFile, node *ast.Node) c
pos := SkipTrivia(sourceFile.Text(), node.Pos())
body := node.AsArrowFunction().Body
if body != nil && body.Kind == ast.KindBlock {
startLine, _ := GetECMALineAndCharacterOfPosition(sourceFile, body.Pos())
endLine, _ := GetECMALineAndCharacterOfPosition(sourceFile, body.End())
startLine := GetECMALineOfPosition(sourceFile, body.Pos())
endLine := GetECMALineOfPosition(sourceFile, body.End())
if startLine < endLine {
// The arrow function spans multiple lines,
// make the error span be the first line, inclusive.
Expand Down Expand Up @@ -2434,9 +2434,15 @@ func GetECMALineStarts(sourceFile ast.SourceFileLike) []core.TextPos {
return sourceFile.ECMALineMap()
}

func GetECMALineOfPosition(sourceFile ast.SourceFileLike, pos int) int {
lineMap := GetECMALineStarts(sourceFile)
return ComputeLineOfPosition(lineMap, pos)
}

func GetECMALineAndCharacterOfPosition(sourceFile ast.SourceFileLike, pos int) (line int, character int) {
lineMap := GetECMALineStarts(sourceFile)
line = ComputeLineOfPosition(lineMap, pos)
// !!! TODO: this is suspect; these are rune counts, not UTF-8 _or_ UTF-16 offsets.
character = utf8.RuneCountInString(sourceFile.Text()[lineMap[line]:pos])
return line, character
}
Expand Down
2 changes: 1 addition & 1 deletion internal/testutil/tsbaseline/type_symbol_baseline.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func forEachASTNode(node *ast.Node) []*ast.Node {

func (walker *typeWriterWalker) writeTypeOrSymbol(node *ast.Node, isSymbolWalk bool) *typeWriterResult {
actualPos := scanner.SkipTrivia(walker.currentSourceFile.Text(), node.Pos())
line, _ := scanner.GetECMALineAndCharacterOfPosition(walker.currentSourceFile, actualPos)
line := scanner.GetECMALineOfPosition(walker.currentSourceFile, actualPos)
sourceText := scanner.GetSourceTextOfNodeFromSourceFile(walker.currentSourceFile, node, false /*includeTrivia*/)
fileChecker, done := walker.getTypeCheckerForCurrentFile()
defer done()
Expand Down
4 changes: 2 additions & 2 deletions internal/transformers/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ func IsOriginalNodeSingleLine(emitContext *printer.EmitContext, node *ast.Node)
if source == nil {
return false
}
startLine, _ := scanner.GetECMALineAndCharacterOfPosition(source, original.Loc.Pos())
endLine, _ := scanner.GetECMALineAndCharacterOfPosition(source, original.Loc.End())
startLine := scanner.GetECMALineOfPosition(source, original.Loc.Pos())
endLine := scanner.GetECMALineOfPosition(source, original.Loc.End())
return startLine == endLine
}

Expand Down
Loading