Alex Rickabaugh a7155bc2fa test(language-service): move existing tests to legacy directory (#39594)
In preparation for in-memory testing infrastructure, the existing Ivy
language service tests are moved to a `legacy` directory. These existing
tests rely on a single integration project in `test/project/app`, which
presents a number of challenges:

 * adding extra fields/properties to the integration project for one test
   can cause others to fail/flake.
 * it's especially difficult to test any cases that require introducing
   intentional errors, as those tend to break other tests.
 * tests load files from disk, which is slower.
 * tests rely on the real built versions of @angular/core and
   @angular/common, which makes them both slow to build and require rebuilds
   on every compiler change.
 * tests share a single tsconfig.json, making it extremely difficult to test
   how the language service handles different configuration scenarios (e.g.
   different type-checking flags).

PR Close #39594
2020-11-17 11:59:56 -08:00

28 lines
843 B
TypeScript

/**
* @license
* Copyright Google LLC 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 {MockService} from './mock_host';
export interface HumanizedDefinitionInfo {
fileName: string;
textSpan: string;
contextSpan: string|undefined;
}
export function humanizeDefinitionInfo(
def: ts.DefinitionInfo, service: MockService): HumanizedDefinitionInfo {
const snapshot = service.getScriptInfo(def.fileName).getSnapshot();
return {
fileName: def.fileName,
textSpan: snapshot.getText(def.textSpan.start, def.textSpan.start + def.textSpan.length),
contextSpan: def.contextSpan ?
snapshot.getText(def.contextSpan.start, def.contextSpan.start + def.contextSpan.length) :
undefined,
};
}