fix(language-service): Remove getExternalFiles() (#34260)
This commit removes the `getExternalFiles()` from the tsserver plugin. This API is no longer needed now that we do not intend to support external templates under the plugin mode. Instead, the external files are added to the project only when they are opened by the user. For complete discussion, see https://github.com/angular/vscode-ng-language-service/issues/473 PR closes https://github.com/angular/vscode-ng-language-service/issues/469 PR closes https://github.com/angular/vscode-ng-language-service/issues/473 PR Close #34260
This commit is contained in:

committed by
Andrew Kushnir

parent
99745009a8
commit
0e911f87b0
@ -11,50 +11,8 @@ import * as tss from 'typescript/lib/tsserverlibrary';
|
||||
import {createLanguageService} from './language_service';
|
||||
import {TypeScriptServiceHost} from './typescript_host';
|
||||
|
||||
/**
|
||||
* A note about importing TypeScript module.
|
||||
* The TypeScript module is supplied by tsserver at runtime to ensure version
|
||||
* compatibility. In Angular language service, the rollup output is augmented
|
||||
* with a "banner" shim that overwrites 'typescript' and
|
||||
* 'typescript/lib/tsserverlibrary' imports with the value supplied by tsserver.
|
||||
* This means import of either modules will not be "required", but they'll work
|
||||
* just like regular imports.
|
||||
*/
|
||||
|
||||
const projectHostMap = new WeakMap<tss.server.Project, TypeScriptServiceHost>();
|
||||
|
||||
/**
|
||||
* Return the external templates discovered through processing all NgModules in
|
||||
* the specified `project`.
|
||||
* This function is called in a few situations:
|
||||
* 1. When a ConfiguredProject is created
|
||||
* https://github.com/microsoft/TypeScript/blob/c26c44d5fceb04ea14da20b6ed23449df777ff34/src/server/editorServices.ts#L1755
|
||||
* 2. When updateGraph() is called on a Project
|
||||
* https://github.com/microsoft/TypeScript/blob/c26c44d5fceb04ea14da20b6ed23449df777ff34/src/server/project.ts#L915
|
||||
* @param project Most likely a ConfiguredProject
|
||||
*/
|
||||
export function getExternalFiles(project: tss.server.Project): string[] {
|
||||
if (!project.hasRoots()) {
|
||||
// During project initialization where there is no root files yet we should
|
||||
// not do any work.
|
||||
return [];
|
||||
}
|
||||
const ngLSHost = projectHostMap.get(project);
|
||||
if (!ngLSHost) {
|
||||
// Without an Angular host there is no way to get template references.
|
||||
return [];
|
||||
}
|
||||
const templates = ngLSHost.getTemplateReferences();
|
||||
const logger = project.projectService.logger;
|
||||
if (logger.hasLevel(tss.server.LogLevel.verbose)) {
|
||||
// Log external files to help debugging.
|
||||
logger.info(`External files in ${project.projectName}: ${JSON.stringify(templates)}`);
|
||||
}
|
||||
return templates;
|
||||
}
|
||||
|
||||
export function create(info: tss.server.PluginCreateInfo): tss.LanguageService {
|
||||
const {project, languageService: tsLS, languageServiceHost: tsLSHost, config} = info;
|
||||
const {languageService: tsLS, languageServiceHost: tsLSHost, config} = info;
|
||||
// This plugin could operate under two different modes:
|
||||
// 1. TS + Angular
|
||||
// Plugin augments TS language service to provide additional Angular
|
||||
@ -67,7 +25,6 @@ export function create(info: tss.server.PluginCreateInfo): tss.LanguageService {
|
||||
const angularOnly = config ? config.angularOnly === true : false;
|
||||
const ngLSHost = new TypeScriptServiceHost(tsLSHost, tsLS);
|
||||
const ngLS = createLanguageService(ngLSHost);
|
||||
projectHostMap.set(project, ngLSHost);
|
||||
|
||||
function getCompletionsAtPosition(
|
||||
fileName: string, position: number,
|
||||
|
Reference in New Issue
Block a user