style(compiler-cli): reformat of codebase with new clang-format version (#36520)
This commit reformats the packages/compiler-cli tree using the new version of clang-format. PR Close #36520
This commit is contained in:
@ -8,16 +8,22 @@
|
||||
|
||||
import * as ts from 'typescript';
|
||||
|
||||
export type Entry = string | Directory;
|
||||
export type Entry = string|Directory;
|
||||
|
||||
export interface Directory { [name: string]: Entry; }
|
||||
export interface Directory {
|
||||
[name: string]: Entry;
|
||||
}
|
||||
|
||||
export class MockAotContext {
|
||||
private files: Entry[];
|
||||
|
||||
constructor(public currentDirectory: string, ...files: Entry[]) { this.files = files; }
|
||||
constructor(public currentDirectory: string, ...files: Entry[]) {
|
||||
this.files = files;
|
||||
}
|
||||
|
||||
fileExists(fileName: string): boolean { return typeof this.getEntry(fileName) === 'string'; }
|
||||
fileExists(fileName: string): boolean {
|
||||
return typeof this.getEntry(fileName) === 'string';
|
||||
}
|
||||
|
||||
directoryExists(path: string): boolean {
|
||||
return path === this.currentDirectory || typeof this.getEntry(path) === 'object';
|
||||
@ -28,7 +34,7 @@ export class MockAotContext {
|
||||
if (typeof data === 'string') {
|
||||
return data;
|
||||
}
|
||||
return undefined !;
|
||||
return undefined!;
|
||||
}
|
||||
|
||||
readResource(fileName: string): Promise<string> {
|
||||
@ -41,14 +47,16 @@ export class MockAotContext {
|
||||
|
||||
writeFile(fileName: string, data: string): void {
|
||||
const parts = fileName.split('/');
|
||||
const name = parts.pop() !;
|
||||
const name = parts.pop()!;
|
||||
const entry = this.getEntry(parts);
|
||||
if (entry && typeof entry !== 'string') {
|
||||
entry[name] = data;
|
||||
}
|
||||
}
|
||||
|
||||
assumeFileExists(fileName: string): void { this.writeFile(fileName, ''); }
|
||||
assumeFileExists(fileName: string): void {
|
||||
this.writeFile(fileName, '');
|
||||
}
|
||||
|
||||
getEntry(fileName: string|string[]): Entry|undefined {
|
||||
let parts = typeof fileName === 'string' ? fileName.split('/') : fileName;
|
||||
@ -69,7 +77,9 @@ export class MockAotContext {
|
||||
}
|
||||
}
|
||||
|
||||
override(files: Entry) { return new MockAotContext(this.currentDirectory, files, ...this.files); }
|
||||
override(files: Entry) {
|
||||
return new MockAotContext(this.currentDirectory, files, ...this.files);
|
||||
}
|
||||
}
|
||||
|
||||
function first<T>(a: T[], cb: (value: T) => T | undefined): T|undefined {
|
||||
@ -82,7 +92,7 @@ function first<T>(a: T[], cb: (value: T) => T | undefined): T|undefined {
|
||||
function getEntryFromFiles(parts: string[], files: Entry) {
|
||||
let current = files;
|
||||
while (parts.length) {
|
||||
const part = parts.shift() !;
|
||||
const part = parts.shift()!;
|
||||
if (typeof current === 'string') {
|
||||
return undefined;
|
||||
}
|
||||
@ -98,7 +108,7 @@ function getEntryFromFiles(parts: string[], files: Entry) {
|
||||
function normalize(parts: string[]): string[] {
|
||||
const result: string[] = [];
|
||||
while (parts.length) {
|
||||
const part = parts.shift() !;
|
||||
const part = parts.shift()!;
|
||||
switch (part) {
|
||||
case '.':
|
||||
break;
|
||||
@ -115,9 +125,13 @@ function normalize(parts: string[]): string[] {
|
||||
export class MockCompilerHost implements ts.CompilerHost {
|
||||
constructor(private context: MockAotContext) {}
|
||||
|
||||
fileExists(fileName: string): boolean { return this.context.fileExists(fileName); }
|
||||
fileExists(fileName: string): boolean {
|
||||
return this.context.fileExists(fileName);
|
||||
}
|
||||
|
||||
readFile(fileName: string): string { return this.context.readFile(fileName); }
|
||||
readFile(fileName: string): string {
|
||||
return this.context.readFile(fileName);
|
||||
}
|
||||
|
||||
directoryExists(directoryName: string): boolean {
|
||||
return this.context.directoryExists(directoryName);
|
||||
@ -130,7 +144,7 @@ export class MockCompilerHost implements ts.CompilerHost {
|
||||
if (sourceText != null) {
|
||||
return ts.createSourceFile(fileName, sourceText, languageVersion);
|
||||
} else {
|
||||
return undefined !;
|
||||
return undefined!;
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,15 +152,28 @@ export class MockCompilerHost implements ts.CompilerHost {
|
||||
return ts.getDefaultLibFileName(options);
|
||||
}
|
||||
|
||||
writeFile: ts.WriteFileCallback = (fileName, text) => { this.context.writeFile(fileName, text); };
|
||||
writeFile: ts.WriteFileCallback =
|
||||
(fileName, text) => {
|
||||
this.context.writeFile(fileName, text);
|
||||
}
|
||||
|
||||
getCurrentDirectory(): string { return this.context.currentDirectory; }
|
||||
getCurrentDirectory(): string {
|
||||
return this.context.currentDirectory;
|
||||
}
|
||||
|
||||
getCanonicalFileName(fileName: string): string { return fileName; }
|
||||
getCanonicalFileName(fileName: string): string {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
useCaseSensitiveFileNames(): boolean { return false; }
|
||||
useCaseSensitiveFileNames(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
getNewLine(): string { return '\n'; }
|
||||
getNewLine(): string {
|
||||
return '\n';
|
||||
}
|
||||
|
||||
getDirectories(path: string): string[] { return this.context.getDirectories(path); }
|
||||
getDirectories(path: string): string[] {
|
||||
return this.context.getDirectories(path);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user