-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Move function typed properties from the SourceFile to a dedicated functions #1700
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
// from this SourceFile that are being held onto may change as a result (including | ||
// becoming detached from any SourceFile). It is recommended that this SourceFile not | ||
// be used once 'update' is called on it. | ||
export function update(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange): SourceFile { |
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.
Maybe updateSourceFile
?
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.
will change
Looks good, but hard to see exactly what changed in the large blocks that moved. |
Large blocks are mostly auxiliary function that were used by |
@@ -391,7 +391,7 @@ module FourSlash { | |||
this.currentCaretPosition = pos; | |||
|
|||
var lineStarts = ts.computeLineStarts(this.getCurrentFileContent()); | |||
var lineCharPos = ts.getLineAndCharacterOfPosition(lineStarts, pos); | |||
var lineCharPos = ts.computeLineAndCharacterOfPosition(lineStarts, pos); |
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.
What's the difference between this and getLineAndCharacterOfPosition
?
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.
computeLineAndCharacterOfPosition
accepts lineMap as number[]
and use it to compute line and character. getLineAndCharacterOfPosition
accepts SourceFile
, picks lineMap from the file (and initializes it if it was not yet created) and then invokes computeLineAndCharacterOfPosition
👍 |
Move function typed properties from the SourceFile to a dedicated functions
Function typed properties on SourceFile are made with closures, for all source files it will keep the parser instance alive. This PR makes SourceFile pure data object -> no closures are required