@@ -13,7 +13,7 @@ import (
13
13
)
14
14
15
15
func 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 ))
17
17
return getIndentationForNodeWorker (n , startline , startpos , ignoreActualIndentationRange /*indentationDelta*/ , 0 , sourceFile /*isNextChild*/ , false , options )
18
18
}
19
19
@@ -100,7 +100,7 @@ func getIndentationForNodeWorker(
100
100
parent = current .Parent
101
101
102
102
if useTrueStart {
103
- currentStartLine , currentStartCharacter = scanner .GetLineAndCharacterOfPosition (sourceFile , scanner .GetTokenPosOfNode (current , sourceFile , false ))
103
+ currentStartLine , currentStartCharacter = scanner .GetECMALineAndCharacterOfPosition (sourceFile , scanner .GetTokenPosOfNode (current , sourceFile , false ))
104
104
} else {
105
105
currentStartLine = containingListOrParentStartLine
106
106
currentStartCharacter = containingListOrParentStartCharacter
@@ -131,7 +131,7 @@ func isArgumentAndStartLineOverlapsExpressionBeingCalled(parent *ast.Node, child
131
131
return false
132
132
}
133
133
expressionOfCallExpressionEnd := parent .Expression ().End ()
134
- expressionOfCallExpressionEndLine , _ := scanner .GetLineAndCharacterOfPosition (sourceFile , expressionOfCallExpressionEnd )
134
+ expressionOfCallExpressionEndLine , _ := scanner .GetECMALineAndCharacterOfPosition (sourceFile , expressionOfCallExpressionEnd )
135
135
return expressionOfCallExpressionEndLine == childStartLine
136
136
}
137
137
@@ -166,7 +166,7 @@ func getActualIndentationForListStartLine(list *ast.NodeList, sourceFile *ast.So
166
166
if list == nil {
167
167
return - 1
168
168
}
169
- line , char := scanner .GetLineAndCharacterOfPosition (sourceFile , list .Loc .Pos ())
169
+ line , char := scanner .GetECMALineAndCharacterOfPosition (sourceFile , list .Loc .Pos ())
170
170
return findColumnForFirstNonWhitespaceCharacterInLine (line , char , sourceFile , options )
171
171
}
172
172
@@ -185,7 +185,7 @@ func deriveActualIndentationFromList(list *ast.NodeList, index int, sourceFile *
185
185
continue
186
186
}
187
187
// 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 ())
189
189
if prevEndLine != line {
190
190
return findColumnForFirstNonWhitespaceCharacterInLine (line , char , sourceFile , options )
191
191
}
@@ -196,7 +196,7 @@ func deriveActualIndentationFromList(list *ast.NodeList, index int, sourceFile *
196
196
}
197
197
198
198
func 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 )
200
200
return FindFirstNonWhitespaceColumn (lineStart , lineStart + char , sourceFile , options )
201
201
}
202
202
@@ -247,7 +247,7 @@ func childStartsOnTheSameLineWithElseInIfStatement(parent *ast.Node, child *ast.
247
247
}
248
248
249
249
func 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 ))
251
251
}
252
252
253
253
func GetContainingList (node * ast.Node , sourceFile * ast.SourceFile ) * ast.NodeList {
@@ -356,7 +356,7 @@ func getContainingListOrParentStart(parent *ast.Node, child *ast.Node, sourceFil
356
356
} else {
357
357
startPos = scanner .GetTokenPosOfNode (parent , sourceFile , false )
358
358
}
359
- return scanner .GetLineAndCharacterOfPosition (sourceFile , startPos )
359
+ return scanner .GetECMALineAndCharacterOfPosition (sourceFile , startPos )
360
360
}
361
361
362
362
func isControlFlowEndingStatement (kind ast.Kind , parentKind ast.Kind ) bool {
@@ -439,8 +439,8 @@ func NodeWillIndentChild(settings *FormatCodeSettings, parent *ast.Node, child *
439
439
return rangeIsOnOneLine (child .Loc , sourceFile )
440
440
}
441
441
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 ()))
444
444
return parentStartLine != childStartLine
445
445
}
446
446
if parent .Kind != ast .KindBinaryExpression {
@@ -516,7 +516,7 @@ func NodeWillIndentChild(settings *FormatCodeSettings, parent *ast.Node, child *
516
516
// branch beginning on the line that the whenTrue branch ends.
517
517
func childIsUnindentedBranchOfConditionalExpression (parent * ast.Node , child * ast.Node , childStartLine int , sourceFile * ast.SourceFile ) bool {
518
518
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 ())
520
520
if child == parent .AsConditionalExpression ().WhenTrue {
521
521
return childStartLine == conditionEndLine
522
522
} else {
@@ -528,7 +528,7 @@ func childIsUnindentedBranchOfConditionalExpression(parent *ast.Node, child *ast
528
528
// 0 L2: indented two stops, one because whenTrue was indented
529
529
// ); and one because of the parentheses spanning multiple lines
530
530
trueStartLine , _ := getStartLineAndCharacterForNode (parent .AsConditionalExpression ().WhenTrue , sourceFile )
531
- trueEndLine , _ := scanner .GetLineAndCharacterOfPosition (sourceFile , parent .AsConditionalExpression ().WhenTrue .End ())
531
+ trueEndLine , _ := scanner .GetECMALineAndCharacterOfPosition (sourceFile , parent .AsConditionalExpression ().WhenTrue .End ())
532
532
return conditionEndLine == trueStartLine && trueEndLine == childStartLine
533
533
}
534
534
}
@@ -550,7 +550,7 @@ func argumentStartsOnSameLineAsPreviousArgument(parent *ast.Node, child *ast.Nod
550
550
}
551
551
552
552
previousNode := parent .Arguments ()[currentIndex - 1 ]
553
- lineOfPreviousNode , _ := scanner .GetLineAndCharacterOfPosition (sourceFile , previousNode .End ())
553
+ lineOfPreviousNode , _ := scanner .GetECMALineAndCharacterOfPosition (sourceFile , previousNode .End ())
554
554
if childStartLine == lineOfPreviousNode {
555
555
return true
556
556
}
0 commit comments