Break many functions out of services.ts and into their own modules.#10729
Closed
ghost wants to merge 1 commit into
Closed
Break many functions out of services.ts and into their own modules.#10729ghost wants to merge 1 commit into
ghost wants to merge 1 commit into
Conversation
| } | ||
|
|
||
| public getText(sourceFile?: SourceFile): string { | ||
| return (sourceFile || this.getSourceFile()).text.substring(this.getStart(), this.getEnd()); |
Member
There was a problem hiding this comment.
pass sourceFile into this.getStart()
Member
There was a problem hiding this comment.
Make sure to catch sourceFile first.
|
Generally looks ok to me. Though I noticed that As this is a pretty big change, @mhegazy and @vladima may want to take a look as well. |
Author
|
Closed in favor of #10753. |
This pull request was closed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since many of these functions used to be inside a big closure in services.ts, I've had to add new parameters to many of them.
Note that when moving functions out I often create closure/no-closure pairs.
For example, when extracting out
getDocumentHighlights, the new signature has new parameters:So to satisfy the old signatures, we get parameters from the closure and then pass them in.
Here are the changes:
allocators.ts: 625 lines
Exports:
getServicesObjectAllocator, a new function I made so that this module would need only 1 export.classifier.ts: 982 lines
Exports:
createClassifier,getSemanticClassifications,getEncodedSemanticClassifications,getSyntacticClassifications,getEncodedSyntacticClassificationsNew parameters:
checkForClassificationCancellation: cancellationTokengetSemanticClassifications: typeChecker, cancellationToken, sourceFile, classifiableNamesgetEncodedSemanticClassifications: typeChecker, cancellationToken, sourceFile, classifiableNamesgetSyntacticClassifications: cancellationToken, sourceFilegetEncodedSyntacticClassifications: cancellationToken, sourceFilecompletions.ts: 1186 lines
Exports:
getCompletionsAtPosition,getCompletionEntryDetailsNew parameters:
getCompletionEntryDisplayNameForSymbol: typeCheckergetCompletionEntryDetails: typeChecker, log, target, sourceFilegetCompletionsAtPosition: typeChecker, log, target, sourceFilegetCompletionData: typeChecker, log, sourceFiledocumentHighlights.ts: 638 lines
Exports:
getDocumentHighlightsNew parameters:
getDocumentHighlights: typeChecker, cancellationToken, sourceFilefindAllReferences.ts: 1102 lines
Exports:
getReferencedSymbolsForNodeNew parameters:
getReferencedSymbolsForNode: typeChecker, cancellationTokengoToDefinition.ts: 257 lines
Exports:
getDefinitionAtPosition,getTypeDefinitionAtPositionNew parameters:
getDefinitionAtPosition: program, sourcefile(I didn't want to pass in the whole program, but
tryResolveScriptReferencerequires it and I don't want to do any refactoring in this commit.)createDefinitionFromSignatureDeclaration: typeCheckergetDefinitionFromSymbol: typeCheckergetTypeDefinitionAtPosition: typeChecker, sourceFilejsDoc.ts: 403 lines
Exports:
getJsDocCommentsFromDeclarations,getAllJsDocCompletionEntriessymbolDisplay.ts: 524 lines
Exports:
getSymbolKind,getSymbolModifiers,getSymbolDisplayPartsDocumentationAndSymbolKindNew parameters:
getSymbolDisplayPartsDocumentationAndSymbolKind: typeCheckergetSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar: typeCheckergetSymbolKind: typeCheckerutilities.ts:
Has 428 lines of new utilities at the top, taken out of
services.ts.I've checked that these are all used in multiple modules (else I would have moved them to the module they are used in).
Breaking the now 1376 lines of utilities apart into logical categories will be a job for another PR.
Other changes
program.gettypeChecker()have been replaced to justtypeCheckerparameter accesses. This should have no effect since getTypeChecker only has side effects the first time it is called.