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:
Alex Rickabaugh
2020-04-07 12:43:43 -07:00
committed by atscott
parent 717df13207
commit 0a69a2832b
205 changed files with 2949 additions and 2122 deletions

View File

@ -12,7 +12,7 @@ import {ModuleResolver} from '../../imports';
import {PartialEvaluator} from '../../partial_evaluator';
import {scanForCandidateTransitiveModules, scanForRouteEntryPoints} from './lazy';
import {RouterEntryPointManager, entryPointKeyFor} from './route';
import {entryPointKeyFor, RouterEntryPointManager} from './route';
export interface NgModuleRawRouteData {
sourceFile: ts.SourceFile;
@ -42,10 +42,13 @@ export class NgModuleRouteAnalyzer {
if (this.modules.has(key)) {
throw new Error(`Double route analyzing for '${key}'.`);
}
this.modules.set(
key, {
sourceFile, moduleName, imports, exports, providers,
});
this.modules.set(key, {
sourceFile,
moduleName,
imports,
exports,
providers,
});
}
listLazyRoutes(entryModuleKey?: string|undefined): LazyRoute[] {
@ -63,7 +66,7 @@ export class NgModuleRouteAnalyzer {
const scanRecursively = entryModuleKey !== undefined;
while (pendingModuleKeys.length > 0) {
const key = pendingModuleKeys.pop() !;
const key = pendingModuleKeys.pop()!;
if (scannedModuleKeys.has(key)) {
continue;
@ -71,7 +74,7 @@ export class NgModuleRouteAnalyzer {
scannedModuleKeys.add(key);
}
const data = this.modules.get(key) !;
const data = this.modules.get(key)!;
const entryPoints = scanForRouteEntryPoints(
data.sourceFile, data.moduleName, data, this.entryPointManager, this.evaluator);

View File

@ -12,7 +12,7 @@ import {Reference} from '../../imports';
import {ForeignFunctionResolver, PartialEvaluator, ResolvedValue} from '../../partial_evaluator';
import {NgModuleRawRouteData} from './analyzer';
import {RouterEntryPoint, RouterEntryPointManager, entryPointKeyFor} from './route';
import {entryPointKeyFor, RouterEntryPoint, RouterEntryPointManager} from './route';
const ROUTES_MARKER = '__ngRoutesMarker__';
@ -23,7 +23,7 @@ export interface LazyRouteEntry {
}
export function scanForCandidateTransitiveModules(
expr: ts.Expression | null, evaluator: PartialEvaluator): string[] {
expr: ts.Expression|null, evaluator: PartialEvaluator): string[] {
if (expr === null) {
return [];
}
@ -38,7 +38,7 @@ export function scanForCandidateTransitiveModules(
}
} else if (entry instanceof Map) {
if (entry.has('ngModule')) {
recursivelyAddModules(entry.get('ngModule') !);
recursivelyAddModules(entry.get('ngModule')!);
}
} else if ((entry instanceof Reference) && hasIdentifier(entry.node)) {
const filePath = entry.node.getSourceFile().fileName;
@ -70,7 +70,9 @@ export function scanForRouteEntryPoints(
const resolvedTo = entryPointManager.resolveLoadChildrenIdentifier(loadChildren, ngModule);
if (resolvedTo !== null) {
routes.push({
loadChildren, from, resolvedTo,
loadChildren,
from,
resolvedTo,
});
}
}
@ -159,29 +161,27 @@ function scanForLazyRoutes(routes: ResolvedValue[]): string[] {
const routerModuleFFR: ForeignFunctionResolver =
function routerModuleFFR(
ref: Reference<ts.FunctionDeclaration|ts.MethodDeclaration|ts.FunctionExpression>,
args: ReadonlyArray<ts.Expression>): ts.Expression |
null {
if (!isMethodNodeReference(ref) || !ts.isClassDeclaration(ref.node.parent)) {
return null;
} else if (
ref.bestGuessOwningModule === null ||
ref.bestGuessOwningModule.specifier !== '@angular/router') {
return null;
} else if (
ref.node.parent.name === undefined || ref.node.parent.name.text !== 'RouterModule') {
return null;
} else if (
!ts.isIdentifier(ref.node.name) ||
(ref.node.name.text !== 'forRoot' && ref.node.name.text !== 'forChild')) {
return null;
}
args: ReadonlyArray<ts.Expression>): ts.Expression|null {
if (!isMethodNodeReference(ref) || !ts.isClassDeclaration(ref.node.parent)) {
return null;
} else if (
ref.bestGuessOwningModule === null ||
ref.bestGuessOwningModule.specifier !== '@angular/router') {
return null;
} else if (ref.node.parent.name === undefined || ref.node.parent.name.text !== 'RouterModule') {
return null;
} else if (
!ts.isIdentifier(ref.node.name) ||
(ref.node.name.text !== 'forRoot' && ref.node.name.text !== 'forChild')) {
return null;
}
const routes = args[0];
return ts.createObjectLiteral([
ts.createPropertyAssignment(ROUTES_MARKER, ts.createTrue()),
ts.createPropertyAssignment('routes', routes),
]);
};
const routes = args[0];
return ts.createObjectLiteral([
ts.createPropertyAssignment(ROUTES_MARKER, ts.createTrue()),
ts.createPropertyAssignment('routes', routes),
]);
};
function hasIdentifier(node: ts.Node): node is ts.Node&{name: ts.Identifier} {
const node_ = node as ts.NamedDeclaration;

View File

@ -22,10 +22,14 @@ export abstract class RouterEntryPoint {
class RouterEntryPointImpl implements RouterEntryPoint {
constructor(readonly filePath: string, readonly moduleName: string) {}
get name(): string { return this.moduleName; }
get name(): string {
return this.moduleName;
}
// For debugging purposes.
toString(): string { return `RouterEntryPoint(name: ${this.name}, filePath: ${this.filePath})`; }
toString(): string {
return `RouterEntryPoint(name: ${this.name}, filePath: ${this.filePath})`;
}
}
export class RouterEntryPointManager {
@ -51,7 +55,7 @@ export class RouterEntryPointManager {
if (!this.map.has(key)) {
this.map.set(key, new RouterEntryPointImpl(sf.fileName, moduleName));
}
return this.map.get(key) !;
return this.map.get(key)!;
}
}