@@ -84,13 +84,13 @@ func FormatDiagnosticWithColorAndContext(output io.Writer, diagnostic *ast.Diagn
84
84
}
85
85
86
86
func writeCodeSnippet (writer io.Writer , sourceFile * ast.SourceFile , start int , length int , squiggleColor string , indent string , formatOpts * FormattingOptions ) {
87
- firstLine , firstLineChar := scanner .GetLineAndCharacterOfPosition (sourceFile , start )
88
- lastLine , lastLineChar := scanner .GetLineAndCharacterOfPosition (sourceFile , start + length )
87
+ firstLine , firstLineChar := scanner .GetECMALineAndCharacterOfPosition (sourceFile , start )
88
+ lastLine , lastLineChar := scanner .GetECMALineAndCharacterOfPosition (sourceFile , start + length )
89
89
if length == 0 {
90
90
lastLineChar ++ // When length is zero, squiggle the character right after the start position.
91
91
}
92
92
93
- lastLineOfFile , _ := scanner .GetLineAndCharacterOfPosition (sourceFile , len (sourceFile .Text ()))
93
+ lastLineOfFile , _ := scanner .GetECMALineAndCharacterOfPosition (sourceFile , len (sourceFile .Text ()))
94
94
95
95
hasMoreThanFiveLines := lastLine - firstLine >= 4
96
96
gutterWidth := len (strconv .Itoa (lastLine + 1 ))
@@ -113,10 +113,10 @@ func writeCodeSnippet(writer io.Writer, sourceFile *ast.SourceFile, start int, l
113
113
i = lastLine - 1
114
114
}
115
115
116
- lineStart := scanner .GetPositionOfLineAndCharacter (sourceFile , i , 0 )
116
+ lineStart := scanner .GetECMAPositionOfLineAndCharacter (sourceFile , i , 0 )
117
117
var lineEnd int
118
118
if i < lastLineOfFile {
119
- lineEnd = scanner .GetPositionOfLineAndCharacter (sourceFile , i + 1 , 0 )
119
+ lineEnd = scanner .GetECMAPositionOfLineAndCharacter (sourceFile , i + 1 , 0 )
120
120
} else {
121
121
lineEnd = sourceFile .Loc .End ()
122
122
}
@@ -216,7 +216,7 @@ func writeWithStyleAndReset(output io.Writer, text string, formatStyle string) {
216
216
}
217
217
218
218
func WriteLocation (output io.Writer , file * ast.SourceFile , pos int , formatOpts * FormattingOptions , writeWithStyleAndReset FormattedWriter ) {
219
- firstLine , firstChar := scanner .GetLineAndCharacterOfPosition (file , pos )
219
+ firstLine , firstChar := scanner .GetECMALineAndCharacterOfPosition (file , pos )
220
220
var relativeFileName string
221
221
if formatOpts != nil {
222
222
relativeFileName = tspath .ConvertToRelativePath (file .FileName (), formatOpts .ComparePathsOptions )
@@ -357,7 +357,7 @@ func prettyPathForFileError(file *ast.SourceFile, fileErrors []*ast.Diagnostic,
357
357
if file == nil || len (fileErrors ) == 0 {
358
358
return ""
359
359
}
360
- line , _ := scanner .GetLineAndCharacterOfPosition (file , fileErrors [0 ].Loc ().Pos ())
360
+ line , _ := scanner .GetECMALineAndCharacterOfPosition (file , fileErrors [0 ].Loc ().Pos ())
361
361
fileName := file .FileName ()
362
362
if tspath .PathIsAbsolute (fileName ) && tspath .PathIsAbsolute (formatOpts .CurrentDirectory ) {
363
363
fileName = tspath .ConvertToRelativePath (file .FileName (), formatOpts .ComparePathsOptions )
@@ -378,7 +378,7 @@ func WriteFormatDiagnostics(output io.Writer, diagnostics []*ast.Diagnostic, for
378
378
379
379
func WriteFormatDiagnostic (output io.Writer , diagnostic * ast.Diagnostic , formatOpts * FormattingOptions ) {
380
380
if diagnostic .File () != nil {
381
- line , character := scanner .GetLineAndCharacterOfPosition (diagnostic .File (), diagnostic .Loc ().Pos ())
381
+ line , character := scanner .GetECMALineAndCharacterOfPosition (diagnostic .File (), diagnostic .Loc ().Pos ())
382
382
fileName := diagnostic .File ().FileName ()
383
383
relativeFileName := tspath .ConvertToRelativePath (fileName , formatOpts .ComparePathsOptions )
384
384
fmt .Fprintf (output , "%s(%d,%d): " , relativeFileName , line + 1 , character + 1 )
0 commit comments