@@ -13,7 +13,7 @@ import (
1313)
1414
1515func GetIndentationForNode (n * ast.Node , ignoreActualIndentationRange * core.TextRange , sourceFile * ast.SourceFile , options * FormatCodeSettings ) int {
16- startline , startpos := scanner .GetLineAndCharacterOfPosition (sourceFile , scanner .GetTokenPosOfNode (n , sourceFile , false ))
16+ startline , startpos := scanner .GetECMALineAndCharacterOfPosition (sourceFile , scanner .GetTokenPosOfNode (n , sourceFile , false ))
1717 return getIndentationForNodeWorker (n , startline , startpos , ignoreActualIndentationRange /*indentationDelta*/ , 0 , sourceFile /*isNextChild*/ , false , options )
1818}
1919
@@ -100,7 +100,7 @@ func getIndentationForNodeWorker(
100100 parent = current .Parent
101101
102102 if useTrueStart {
103- currentStartLine , currentStartCharacter = scanner .GetLineAndCharacterOfPosition (sourceFile , scanner .GetTokenPosOfNode (current , sourceFile , false ))
103+ currentStartLine , currentStartCharacter = scanner .GetECMALineAndCharacterOfPosition (sourceFile , scanner .GetTokenPosOfNode (current , sourceFile , false ))
104104 } else {
105105 currentStartLine = containingListOrParentStartLine
106106 currentStartCharacter = containingListOrParentStartCharacter
@@ -131,7 +131,7 @@ func isArgumentAndStartLineOverlapsExpressionBeingCalled(parent *ast.Node, child
131131 return false
132132 }
133133 expressionOfCallExpressionEnd := parent .Expression ().End ()
134- expressionOfCallExpressionEndLine , _ := scanner .GetLineAndCharacterOfPosition (sourceFile , expressionOfCallExpressionEnd )
134+ expressionOfCallExpressionEndLine , _ := scanner .GetECMALineAndCharacterOfPosition (sourceFile , expressionOfCallExpressionEnd )
135135 return expressionOfCallExpressionEndLine == childStartLine
136136}
137137
@@ -166,7 +166,7 @@ func getActualIndentationForListStartLine(list *ast.NodeList, sourceFile *ast.So
166166 if list == nil {
167167 return - 1
168168 }
169- line , char := scanner .GetLineAndCharacterOfPosition (sourceFile , list .Loc .Pos ())
169+ line , char := scanner .GetECMALineAndCharacterOfPosition (sourceFile , list .Loc .Pos ())
170170 return findColumnForFirstNonWhitespaceCharacterInLine (line , char , sourceFile , options )
171171}
172172
@@ -185,7 +185,7 @@ func deriveActualIndentationFromList(list *ast.NodeList, index int, sourceFile *
185185 continue
186186 }
187187 // skip list items that ends on the same line with the current list element
188- prevEndLine , _ := scanner .GetLineAndCharacterOfPosition (sourceFile , list .Nodes [i ].End ())
188+ prevEndLine , _ := scanner .GetECMALineAndCharacterOfPosition (sourceFile , list .Nodes [i ].End ())
189189 if prevEndLine != line {
190190 return findColumnForFirstNonWhitespaceCharacterInLine (line , char , sourceFile , options )
191191 }
@@ -196,7 +196,7 @@ func deriveActualIndentationFromList(list *ast.NodeList, index int, sourceFile *
196196}
197197
198198func findColumnForFirstNonWhitespaceCharacterInLine (line int , char int , sourceFile * ast.SourceFile , options * FormatCodeSettings ) int {
199- lineStart := scanner .GetPositionOfLineAndCharacter (sourceFile , line , 0 )
199+ lineStart := scanner .GetECMAPositionOfLineAndCharacter (sourceFile , line , 0 )
200200 return FindFirstNonWhitespaceColumn (lineStart , lineStart + char , sourceFile , options )
201201}
202202
@@ -247,7 +247,7 @@ func childStartsOnTheSameLineWithElseInIfStatement(parent *ast.Node, child *ast.
247247}
248248
249249func getStartLineAndCharacterForNode (n * ast.Node , sourceFile * ast.SourceFile ) (line int , character int ) {
250- return scanner .GetLineAndCharacterOfPosition (sourceFile , scanner .GetTokenPosOfNode (n , sourceFile , false ))
250+ return scanner .GetECMALineAndCharacterOfPosition (sourceFile , scanner .GetTokenPosOfNode (n , sourceFile , false ))
251251}
252252
253253func GetContainingList (node * ast.Node , sourceFile * ast.SourceFile ) * ast.NodeList {
@@ -356,7 +356,7 @@ func getContainingListOrParentStart(parent *ast.Node, child *ast.Node, sourceFil
356356 } else {
357357 startPos = scanner .GetTokenPosOfNode (parent , sourceFile , false )
358358 }
359- return scanner .GetLineAndCharacterOfPosition (sourceFile , startPos )
359+ return scanner .GetECMALineAndCharacterOfPosition (sourceFile , startPos )
360360}
361361
362362func isControlFlowEndingStatement (kind ast.Kind , parentKind ast.Kind ) bool {
@@ -439,8 +439,8 @@ func NodeWillIndentChild(settings *FormatCodeSettings, parent *ast.Node, child *
439439 return rangeIsOnOneLine (child .Loc , sourceFile )
440440 }
441441 if parent .Kind == ast .KindBinaryExpression && sourceFile != nil && childKind == ast .KindJsxElement {
442- parentStartLine , _ := scanner .GetLineAndCharacterOfPosition (sourceFile , scanner .SkipTrivia (sourceFile .Text (), parent .Pos ()))
443- childStartLine , _ := scanner .GetLineAndCharacterOfPosition (sourceFile , scanner .SkipTrivia (sourceFile .Text (), child .Pos ()))
442+ parentStartLine , _ := scanner .GetECMALineAndCharacterOfPosition (sourceFile , scanner .SkipTrivia (sourceFile .Text (), parent .Pos ()))
443+ childStartLine , _ := scanner .GetECMALineAndCharacterOfPosition (sourceFile , scanner .SkipTrivia (sourceFile .Text (), child .Pos ()))
444444 return parentStartLine != childStartLine
445445 }
446446 if parent .Kind != ast .KindBinaryExpression {
@@ -516,7 +516,7 @@ func NodeWillIndentChild(settings *FormatCodeSettings, parent *ast.Node, child *
516516// branch beginning on the line that the whenTrue branch ends.
517517func childIsUnindentedBranchOfConditionalExpression (parent * ast.Node , child * ast.Node , childStartLine int , sourceFile * ast.SourceFile ) bool {
518518 if parent .Kind == ast .KindConditionalExpression && (child == parent .AsConditionalExpression ().WhenTrue || child == parent .AsConditionalExpression ().WhenFalse ) {
519- conditionEndLine , _ := scanner .GetLineAndCharacterOfPosition (sourceFile , parent .AsConditionalExpression ().Condition .End ())
519+ conditionEndLine , _ := scanner .GetECMALineAndCharacterOfPosition (sourceFile , parent .AsConditionalExpression ().Condition .End ())
520520 if child == parent .AsConditionalExpression ().WhenTrue {
521521 return childStartLine == conditionEndLine
522522 } else {
@@ -528,7 +528,7 @@ func childIsUnindentedBranchOfConditionalExpression(parent *ast.Node, child *ast
528528 // 0 L2: indented two stops, one because whenTrue was indented
529529 // ); and one because of the parentheses spanning multiple lines
530530 trueStartLine , _ := getStartLineAndCharacterForNode (parent .AsConditionalExpression ().WhenTrue , sourceFile )
531- trueEndLine , _ := scanner .GetLineAndCharacterOfPosition (sourceFile , parent .AsConditionalExpression ().WhenTrue .End ())
531+ trueEndLine , _ := scanner .GetECMALineAndCharacterOfPosition (sourceFile , parent .AsConditionalExpression ().WhenTrue .End ())
532532 return conditionEndLine == trueStartLine && trueEndLine == childStartLine
533533 }
534534 }
@@ -550,7 +550,7 @@ func argumentStartsOnSameLineAsPreviousArgument(parent *ast.Node, child *ast.Nod
550550 }
551551
552552 previousNode := parent .Arguments ()[currentIndex - 1 ]
553- lineOfPreviousNode , _ := scanner .GetLineAndCharacterOfPosition (sourceFile , previousNode .End ())
553+ lineOfPreviousNode , _ := scanner .GetECMALineAndCharacterOfPosition (sourceFile , previousNode .End ())
554554 if childStartLine == lineOfPreviousNode {
555555 return true
556556 }
0 commit comments