-
Notifications
You must be signed in to change notification settings - Fork 714
Rename line maps with ECMA/LSP prefix #1786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR renames line map-related functions to distinguish between ECMA line maps and LSP line maps. ECMA line maps consider additional characters (like various Unicode line breaks) as line separators beyond just \n
and \r\n
, while LSP uses only standard line terminators.
Key changes:
- Renamed functions from
GetLineAndCharacterOfPosition
toGetECMALineAndCharacterOfPosition
- Updated
ComputeLineStarts
toComputeECMALineStarts
- Changed
LineMap
interface methods toECMALineMap
Reviewed Changes
Copilot reviewed 35 out of 35 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
internal/transformers/utilities.go | Updates function calls to use ECMA line position functions |
internal/transformers/jsxtransforms/jsx.go | Updates JSX transformer to use ECMA line positioning |
internal/testutil/tsbaseline/*.go | Updates baseline test utilities to use ECMA line functions |
internal/sourcemap/*.go | Renames LineInfo to ECMALineInfo and updates related functions |
internal/scanner/scanner.go | Renames core line mapping functions with ECMA prefix |
internal/project/*.go | Updates project files to use LSP line maps where appropriate |
internal/ls/*.go | Renames LineMap to LSPLineMap for language server components |
internal/format/*.go | Updates formatting code to use ECMA line functions |
internal/printer/*.go | Updates printer utilities to use ECMA line positioning |
internal/fourslash/*.go | Updates test framework to use LSP line maps |
internal/diagnosticwriter/diagnosticwriter.go | Updates diagnostic output to use ECMA line positioning |
internal/core/core.go | Renames core line computation functions with ECMA prefix |
internal/compiler/program.go | Updates compiler to use ECMA line functions |
internal/checker/grammarchecks.go | Updates grammar checking to use ECMA line positioning |
internal/astnav/tokens_test.go | Updates test to use ECMA line map |
internal/ast/ast.go | Renames SourceFile LineMap method to ECMALineMap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Boy do I see a lot of stuff we need to rethink 😅
|
||
func GetIndentationForNode(n *ast.Node, ignoreActualIndentationRange *core.TextRange, sourceFile *ast.SourceFile, options *FormatCodeSettings) int { | ||
startline, startpos := scanner.GetLineAndCharacterOfPosition(sourceFile, scanner.GetTokenPosOfNode(n, sourceFile, false)) | ||
startline, startpos := scanner.GetECMALineAndCharacterOfPosition(sourceFile, scanner.GetTokenPosOfNode(n, sourceFile, false)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The formatter using these instead of the client encoding is definitely spooky
lineMapMu sync.RWMutex | ||
lineMap []core.TextPos | ||
ecmaLineMapMu sync.RWMutex | ||
ecmaLineMap []core.TextPos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we give []core.TextPos
a name like ECMALineMap
or does a change like that cause problems elsewhere?
Renaming line map-related functions to make the distinction clear between ECMA and LSP lines.
ECMA line maps/line starts consider characters other than
\n
and\r\n
as line breaks (seestringutil.IsLineBreak
), unlike LSP.This should help avoid future incorrect usages of those functions, and should make it easier to do #1578.