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:
Keen Yee Liau
2019-12-04 12:02:29 -08:00
committed by Andrew Kushnir
parent 99745009a8
commit 0e911f87b0
6 changed files with 3 additions and 110 deletions

View File

@ -12,7 +12,6 @@ ts_library(
"html_info_spec.ts",
"language_service_spec.ts",
"reflector_host_spec.ts",
"template_references_spec.ts",
"template_spec.ts",
"test_utils.ts",
"ts_plugin_spec.ts",

View File

@ -1,45 +0,0 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import * as ts from 'typescript';
import {TypeScriptServiceHost} from '../src/typescript_host';
import {MockTypescriptHost} from './test_utils';
describe('references', () => {
const mockHost = new MockTypescriptHost(['/app/main.ts']);
const service = ts.createLanguageService(mockHost);
const ngHost = new TypeScriptServiceHost(mockHost, service);
beforeEach(() => { mockHost.reset(); });
it('should be able to determine that test.ng is a template reference', () => {
const templates = ngHost.getTemplateReferences();
expect(templates).toEqual(['/app/test.ng']);
});
it('should be able to get template references for an invalid project', () => {
const moduleCode = `
import {NgModule} from '@angular/core';
import {NewClass} from './test.component';
@NgModule({declarations: [NewClass]}) export class TestModule {}`;
const classCode = `
export class NewClass {}
@Component({})
export class SomeComponent {}
`;
mockHost.addScript('/app/test.module.ts', moduleCode);
mockHost.addScript('/app/test.component.ts', classCode);
const templates = ngHost.getTemplateReferences();
expect(templates).toEqual(['/app/test.ng']);
});
});

View File

@ -8,7 +8,7 @@
import * as ts from 'typescript';
import {create, getExternalFiles} from '../src/ts_plugin';
import {create} from '../src/ts_plugin';
import {CompletionKind} from '../src/types';
import {MockTypescriptHost} from './test_utils';
@ -65,11 +65,6 @@ describe('plugin', () => {
}
});
it('should return external templates as external files', () => {
const externalFiles = getExternalFiles(mockProject);
expect(externalFiles).toEqual(['/app/test.ng']);
});
it('should not report template errors on tour of heroes', () => {
const filesWithTemplates = [
// Ignore all '*-cases.ts' files as they intentionally contain errors.