refactor(language-service): language_service_adapter -> adapters (#39619)

This rename is done because we know have a file system adapter over a
project as well as the compiler adapter.

PR Close #39619
This commit is contained in:
ayazhafiz
2020-10-30 17:16:39 -05:00
committed by atscott
parent 64c3135be7
commit d39c4bbe37
6 changed files with 30 additions and 65 deletions
+11 -7
View File
@@ -108,9 +108,10 @@ export function formatDiagnostics(
}
}
/** Used to read configuration files. */
// TODO(ayazhafiz): split FileSystem into a ReadonlyFileSystem and make this a
// subset of that.
export type ParseConfigurationHost =
export type ConfigurationHost =
Pick<FileSystem, 'readFile'|'exists'|'lstat'|'resolve'|'join'|'dirname'|'extname'|'pwd'>;
export interface ParsedConfiguration {
@@ -119,11 +120,11 @@ export interface ParsedConfiguration {
rootNames: string[];
projectReferences?: readonly ts.ProjectReference[]|undefined;
emitFlags: api.EmitFlags;
errors: Diagnostics;
errors: ts.Diagnostic[];
}
export function calcProjectFileAndBasePath(
project: string, host: ParseConfigurationHost = getFileSystem()):
project: string, host: ConfigurationHost = getFileSystem()):
{projectFile: AbsoluteFsPath, basePath: AbsoluteFsPath} {
const absProject = host.resolve(project);
const projectIsDir = host.lstat(absProject).isDirectory();
@@ -145,7 +146,7 @@ export function createNgCompilerOptions(
export function readConfiguration(
project: string, existingOptions?: ts.CompilerOptions,
host: ParseConfigurationHost = getFileSystem()): ParsedConfiguration {
host: ConfigurationHost = getFileSystem()): ParsedConfiguration {
try {
const {projectFile, basePath} = calcProjectFileAndBasePath(project, host);
@@ -223,11 +224,14 @@ export function readConfiguration(
emitFlags
};
} catch (e) {
const errors: Diagnostics = [{
const errors: ts.Diagnostic[] = [{
category: ts.DiagnosticCategory.Error,
messageText: e.stack,
source: api.SOURCE,
code: api.UNKNOWN_ERROR_CODE
file: undefined,
start: undefined,
length: undefined,
source: 'angular',
code: api.UNKNOWN_ERROR_CODE,
}];
return {project: '', errors, rootNames: [], options: {}, emitFlags: api.EmitFlags.Default};
}