style(ngcc): reformat of ngcc after clang update (#36447)
PR Close #36447
This commit is contained in:

committed by
Kara Erickson

parent
c8bef1259c
commit
8be8466a00
@ -12,7 +12,7 @@ import {ParsedConfiguration} from '../../..';
|
||||
import {ComponentDecoratorHandler, DirectiveDecoratorHandler, InjectableDecoratorHandler, NgModuleDecoratorHandler, PipeDecoratorHandler, ReferencesRegistry, ResourceLoader} from '../../../src/ngtsc/annotations';
|
||||
import {CycleAnalyzer, ImportGraph} from '../../../src/ngtsc/cycles';
|
||||
import {isFatalDiagnosticError} from '../../../src/ngtsc/diagnostics';
|
||||
import {FileSystem, LogicalFileSystem, absoluteFrom, dirname, resolve} from '../../../src/ngtsc/file_system';
|
||||
import {absoluteFrom, dirname, FileSystem, LogicalFileSystem, resolve} from '../../../src/ngtsc/file_system';
|
||||
import {AbsoluteModuleStrategy, LocalIdentifierStrategy, LogicalProjectStrategy, ModuleResolver, NOOP_DEFAULT_IMPORT_RECORDER, PrivateExportAliasingHost, Reexport, ReferenceEmitter} from '../../../src/ngtsc/imports';
|
||||
import {CompoundMetadataReader, CompoundMetadataRegistry, DtsMetadataReader, InjectableClassRegistry, LocalMetadataRegistry} from '../../../src/ngtsc/metadata';
|
||||
import {PartialEvaluator} from '../../../src/ngtsc/partial_evaluator';
|
||||
@ -28,7 +28,7 @@ import {EntryPointBundle} from '../packages/entry_point_bundle';
|
||||
import {DefaultMigrationHost} from './migration_host';
|
||||
import {NgccTraitCompiler} from './ngcc_trait_compiler';
|
||||
import {CompiledClass, CompiledFile, DecorationAnalyses} from './types';
|
||||
import {NOOP_DEPENDENCY_TRACKER, isWithinPackage} from './util';
|
||||
import {isWithinPackage, NOOP_DEPENDENCY_TRACKER} from './util';
|
||||
|
||||
|
||||
|
||||
@ -38,8 +38,12 @@ import {NOOP_DEPENDENCY_TRACKER, isWithinPackage} from './util';
|
||||
class NgccResourceLoader implements ResourceLoader {
|
||||
constructor(private fs: FileSystem) {}
|
||||
canPreload = false;
|
||||
preload(): undefined|Promise<void> { throw new Error('Not implemented.'); }
|
||||
load(url: string): string { return this.fs.readFile(resolve(url)); }
|
||||
preload(): undefined|Promise<void> {
|
||||
throw new Error('Not implemented.');
|
||||
}
|
||||
load(url: string): string {
|
||||
return this.fs.readFile(resolve(url));
|
||||
}
|
||||
resolve(url: string, containingFile: string): string {
|
||||
return resolve(dirname(absoluteFrom(containingFile)), url);
|
||||
}
|
||||
@ -56,7 +60,7 @@ export class DecorationAnalyzer {
|
||||
private rootDirs = this.bundle.rootDirs;
|
||||
private packagePath = this.bundle.entryPoint.package;
|
||||
private isCore = this.bundle.isCore;
|
||||
private compilerOptions = this.tsConfig !== null? this.tsConfig.options: {};
|
||||
private compilerOptions = this.tsConfig !== null ? this.tsConfig.options : {};
|
||||
|
||||
moduleResolver =
|
||||
new ModuleResolver(this.program, this.options, this.host, /* moduleResolutionCache */ null);
|
||||
@ -73,8 +77,9 @@ export class DecorationAnalyzer {
|
||||
// based on whether a bestGuessOwningModule is present in the Reference.
|
||||
new LogicalProjectStrategy(this.reflectionHost, new LogicalFileSystem(this.rootDirs)),
|
||||
]);
|
||||
aliasingHost = this.bundle.entryPoint.generateDeepReexports?
|
||||
new PrivateExportAliasingHost(this.reflectionHost): null;
|
||||
aliasingHost = this.bundle.entryPoint.generateDeepReexports ?
|
||||
new PrivateExportAliasingHost(this.reflectionHost) :
|
||||
null;
|
||||
dtsModuleScopeResolver =
|
||||
new MetadataDtsModuleScopeResolver(this.dtsMetaReader, this.aliasingHost);
|
||||
scopeRegistry = new LocalModuleScopeRegistry(
|
||||
@ -191,7 +196,9 @@ export class DecorationAnalyzer {
|
||||
});
|
||||
}
|
||||
|
||||
protected reportDiagnostics() { this.compiler.diagnostics.forEach(this.diagnosticHandler); }
|
||||
protected reportDiagnostics() {
|
||||
this.compiler.diagnostics.forEach(this.diagnosticHandler);
|
||||
}
|
||||
|
||||
protected compileFile(sourceFile: ts.SourceFile): CompiledFile {
|
||||
const constantPool = new ConstantPool();
|
||||
@ -211,7 +218,8 @@ export class DecorationAnalyzer {
|
||||
compiledClasses.push({
|
||||
name: record.node.name.text,
|
||||
decorators: this.compiler.getAllDecorators(record.node),
|
||||
declaration: record.node, compilation
|
||||
declaration: record.node,
|
||||
compilation
|
||||
});
|
||||
}
|
||||
|
||||
@ -224,7 +232,7 @@ export class DecorationAnalyzer {
|
||||
if (!exportStatements.has(sf.fileName)) {
|
||||
return [];
|
||||
}
|
||||
const exports = exportStatements.get(sf.fileName) !;
|
||||
const exports = exportStatements.get(sf.fileName)!;
|
||||
|
||||
const reexports: Reexport[] = [];
|
||||
exports.forEach(([fromModule, symbolName], asAlias) => {
|
||||
|
@ -75,10 +75,9 @@ export class ModuleWithProvidersAnalyzer {
|
||||
const dtsClass = this.host.getDtsDeclaration(containerClass.declaration.valueDeclaration);
|
||||
// Get the declaration of the matching static method
|
||||
dtsFn = dtsClass && ts.isClassDeclaration(dtsClass) ?
|
||||
dtsClass.members
|
||||
.find(
|
||||
member => ts.isMethodDeclaration(member) && ts.isIdentifier(member.name) &&
|
||||
member.name.text === fn.name) as ts.Declaration :
|
||||
dtsClass.members.find(
|
||||
member => ts.isMethodDeclaration(member) && ts.isIdentifier(member.name) &&
|
||||
member.name.text === fn.name) as ts.Declaration :
|
||||
null;
|
||||
} else {
|
||||
dtsFn = this.host.getDtsDeclaration(fn.declaration);
|
||||
@ -87,8 +86,8 @@ export class ModuleWithProvidersAnalyzer {
|
||||
throw new Error(`Matching type declaration for ${fn.declaration.getText()} is missing`);
|
||||
}
|
||||
if (!isFunctionOrMethod(dtsFn)) {
|
||||
throw new Error(
|
||||
`Matching type declaration for ${fn.declaration.getText()} is not a function: ${dtsFn.getText()}`);
|
||||
throw new Error(`Matching type declaration for ${
|
||||
fn.declaration.getText()} is not a function: ${dtsFn.getText()}`);
|
||||
}
|
||||
return dtsFn;
|
||||
}
|
||||
@ -106,12 +105,14 @@ export class ModuleWithProvidersAnalyzer {
|
||||
// to its type declaration.
|
||||
const dtsNgModule = this.host.getDtsDeclaration(ngModule.node);
|
||||
if (!dtsNgModule) {
|
||||
throw new Error(
|
||||
`No typings declaration can be found for the referenced NgModule class in ${fn.declaration.getText()}.`);
|
||||
throw new Error(`No typings declaration can be found for the referenced NgModule class in ${
|
||||
fn.declaration.getText()}.`);
|
||||
}
|
||||
if (!ts.isClassDeclaration(dtsNgModule) || !hasNameIdentifier(dtsNgModule)) {
|
||||
throw new Error(
|
||||
`The referenced NgModule in ${fn.declaration.getText()} is not a named class declaration in the typings program; instead we get ${dtsNgModule.getText()}`);
|
||||
throw new Error(`The referenced NgModule in ${
|
||||
fn.declaration
|
||||
.getText()} is not a named class declaration in the typings program; instead we get ${
|
||||
dtsNgModule.getText()}`);
|
||||
}
|
||||
|
||||
return {node: dtsNgModule, known: null, viaModule: null};
|
||||
|
@ -45,5 +45,7 @@ export class NgccReferencesRegistry implements ReferencesRegistry {
|
||||
* Create and return a mapping for the registered resolved references.
|
||||
* @returns A map of reference identifiers to reference declarations.
|
||||
*/
|
||||
getDeclarationMap(): Map<ts.Identifier, ConcreteDeclaration> { return this.map; }
|
||||
getDeclarationMap(): Map<ts.Identifier, ConcreteDeclaration> {
|
||||
return this.map;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,9 @@ export class NgccTraitCompiler extends TraitCompiler {
|
||||
/* compileNonExportedClasses */ true, new DtsTransformRegistry());
|
||||
}
|
||||
|
||||
get analyzedFiles(): ts.SourceFile[] { return Array.from(this.fileToClasses.keys()); }
|
||||
get analyzedFiles(): ts.SourceFile[] {
|
||||
return Array.from(this.fileToClasses.keys());
|
||||
}
|
||||
|
||||
/**
|
||||
* Analyzes the source file in search for classes to process. For any class that is found in the
|
||||
@ -81,5 +83,7 @@ export class NgccTraitCompiler extends TraitCompiler {
|
||||
}
|
||||
|
||||
class NoIncrementalBuild implements IncrementalBuild<any> {
|
||||
priorWorkFor(sf: ts.SourceFile): any[]|null { return null; }
|
||||
priorWorkFor(sf: ts.SourceFile): any[]|null {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,11 @@
|
||||
*/
|
||||
import * as ts from 'typescript';
|
||||
|
||||
import {AbsoluteFsPath, absoluteFromSourceFile} from '../../../src/ngtsc/file_system';
|
||||
import {absoluteFromSourceFile, AbsoluteFsPath} from '../../../src/ngtsc/file_system';
|
||||
import {ConcreteDeclaration} from '../../../src/ngtsc/reflection';
|
||||
import {NgccReflectionHost} from '../host/ngcc_host';
|
||||
import {hasNameIdentifier, isDefined} from '../utils';
|
||||
|
||||
import {NgccReferencesRegistry} from './ngcc_references_registry';
|
||||
|
||||
export interface ExportInfo {
|
||||
@ -48,7 +49,7 @@ export class PrivateDeclarationsAnalyzer {
|
||||
exports.forEach((declaration, exportedName) => {
|
||||
if (declaration.node !== null && hasNameIdentifier(declaration.node)) {
|
||||
if (privateDeclarations.has(declaration.node.name)) {
|
||||
const privateDeclaration = privateDeclarations.get(declaration.node.name) !;
|
||||
const privateDeclaration = privateDeclarations.get(declaration.node.name)!;
|
||||
if (privateDeclaration.node !== declaration.node) {
|
||||
throw new Error(`${declaration.node.name.text} is declared multiple times.`);
|
||||
}
|
||||
@ -62,7 +63,7 @@ export class PrivateDeclarationsAnalyzer {
|
||||
|
||||
return Array.from(privateDeclarations.keys()).map(id => {
|
||||
const from = absoluteFromSourceFile(id.getSourceFile());
|
||||
const declaration = privateDeclarations.get(id) !;
|
||||
const declaration = privateDeclarations.get(id)!;
|
||||
const dtsDeclaration = this.host.getDtsDeclaration(declaration.node);
|
||||
const dtsFrom = dtsDeclaration && absoluteFromSourceFile(dtsDeclaration.getSourceFile());
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
import * as ts from 'typescript';
|
||||
|
||||
import {AbsoluteFsPath, absoluteFromSourceFile, relative} from '../../../src/ngtsc/file_system';
|
||||
import {absoluteFromSourceFile, AbsoluteFsPath, relative} from '../../../src/ngtsc/file_system';
|
||||
import {DependencyTracker} from '../../../src/ngtsc/incremental/api';
|
||||
|
||||
export function isWithinPackage(packagePath: AbsoluteFsPath, sourceFile: ts.SourceFile): boolean {
|
||||
|
Reference in New Issue
Block a user