Skip to content

Break many functions out of services.ts and into their own modules.#10753

Merged
5 commits merged into
masterfrom
services_modules_2
Sep 8, 2016
Merged

Break many functions out of services.ts and into their own modules.#10753
5 commits merged into
masterfrom
services_modules_2

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Sep 7, 2016

Redo of #10729.

Here are the updated changes:

allocators.ts: 634 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, getEncodedSyntacticClassifications

New parameters:

  • checkForClassificationCancellation: cancellationToken
  • getSemanticClassifications: typeChecker, cancellationToken, sourceFile, classifiableNames
  • getEncodedSemanticClassifications: typeChecker, cancellationToken, sourceFile, classifiableNames
  • getSyntacticClassifications: cancellationToken, sourceFile
  • getEncodedSyntacticClassifications: cancellationToken, sourceFile

completions.ts: 1648 lines

Exports: getCompletionsAtPosition, getCompletionEntryDetails

New parameters:

  • getCompletionsAtPosition: host, typeChecker, log, compilerOptions, sourceFile
  • getCompletionEntryDetails: typeChecker, log, compilerOptions, sourceFile
  • getCompletionData: typeChecker, log, sourceFile
  • getCompletionEntryDisplayNameForSymbol: typeChecker

documentHighlights.ts: 639 lines

Exports: getDocumentHighlights

New parameters:

  • getDocumentHighlights: typeChecker, cancellationToken, sourceFile

findAllReferences.ts: 1126 lines

Exports: findReferencedSymbols, getReferencedSymbolsForNode, convertReferences

New parameters:

  • findReferencedSymbols: typeChecker, cancellationToken, sourceFiles, sourceFile
  • getReferencedSymbolsForNode: typeChecker, cancellationToken

goToDefinition.ts: 257 lines

Exports: getDefinitionAtPosition, getTypeDefinitionAtPosition

New parameters:

  • `getDefinitionAtPosition: program, sourcefile (I didn't want to pass in the whole program, but tryResolveScriptReference requires it and I don't want to do any refactoring in this commit.)
  • createDefinitionFromSignatureDeclaration: typeChecker
  • getDefinitionFromSymbol: typeChecker
  • getTypeDefinitionAtPosition: typeChecker, sourceFile
  • createDefinitionFromSignatureDeclaration: typeChecker

jsDoc.ts: 546 lines

Exports: getJsDocCommentsFromDeclarations, getAllJsDocCompletionEntries, getDocCommentTemplateAtPosition

New parameters:

  • getDocCommentTemplateAtPosition: sourceFile, newLine

meaning.ts: 161 lines

Exports: SemanticMeaning, getMeaningFromDeclaration, getMeaningFromLocation

preProcess.ts: 361 lines

Exports: preProcessFile

rename.ts: 99 lines

Exports: getRenameInfo

New parameters:

getRenameInfo: typeChecker, defaultLibFileName, getCanonicalFileName, sourceFile

symbolDisplay.ts: 524 lines

Exports: getSymbolKind, getSymbolModifiers, getSymbolDisplayPartsDocumentationAndSymbolKind

New parameters:

  • getSymbolDisplayPartsDocumentationAndSymbolKind: typeChecker
  • getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar: typeChecker
  • getSymbolKind: typeChecker

utilities.ts

Everything above line 228 is new.
Breaking the now 1198 lines of utilities apart into logical categories will be a job for another PR.

@ghost
Copy link
Copy Markdown
Author

ghost commented Sep 7, 2016

Re: #10729 (comment)

Every individual function in services.ts is now too small to really justify its own module (and the new PR now gives getRenameInfo its own module), and if a group of them were taken out there would still have to be stub functions left behind that close over program and delegate to the module's function.

So, there would be more sophisticated refactoring involved with any changes made to simplify services now. Trying to keep this PR restricted to just moving code and adding parameters to functions taken out of closures.

@zhengbli
Copy link
Copy Markdown

zhengbli commented Sep 7, 2016

👍 @mhegazy may want to have a look.

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Sep 7, 2016

i would keep allocator.ts in services.ts, move meaning.ts to utilities.ts and move transpile/transpileModule/transpileOptions to a different file

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Sep 7, 2016

otherwise looks good.

…anspile functions to a new file transpile.ts
@ghost ghost merged commit 7f84953 into master Sep 8, 2016
@ghost ghost deleted the services_modules_2 branch September 8, 2016 16:49
@rbuckton
Copy link
Copy Markdown
Contributor

rbuckton commented Sep 8, 2016

This change breaks gulp-tsb, which used ts.preProcessFile as it was part of the public API.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants