Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ import {FileSystem, LogicalFileSystem, absoluteFrom, dirname, resolve} from '../
import {AbsoluteModuleStrategy, LocalIdentifierStrategy, LogicalProjectStrategy, ModuleResolver, NOOP_DEFAULT_IMPORT_RECORDER, ReferenceEmitter} from '../../../src/ngtsc/imports';
import {CompoundMetadataReader, CompoundMetadataRegistry, DtsMetadataReader, LocalMetadataRegistry} from '../../../src/ngtsc/metadata';
import {PartialEvaluator} from '../../../src/ngtsc/partial_evaluator';
import {ClassSymbol} from '../../../src/ngtsc/reflection';
import {LocalModuleScopeRegistry, MetadataDtsModuleScopeResolver} from '../../../src/ngtsc/scope';
import {CompileResult, DecoratorHandler, DetectResult, HandlerPrecedence} from '../../../src/ngtsc/transform';
import {NgccReflectionHost} from '../host/ngcc_host';
import {NgccClassSymbol, NgccReflectionHost} from '../host/ngcc_host';
import {Migration, MigrationHost} from '../migrations/migration';
import {EntryPointBundle} from '../packages/entry_point_bundle';
import {isDefined} from '../utils';
Expand Down Expand Up @@ -128,7 +127,7 @@ export class DecorationAnalyzer {
return analyzedClasses.length ? {sourceFile, analyzedClasses} : undefined;
}

protected analyzeClass(symbol: ClassSymbol): AnalyzedClass|null {
protected analyzeClass(symbol: NgccClassSymbol): AnalyzedClass|null {
const decorators = this.reflectionHost.getDecoratorsOfSymbol(symbol);
const analyzedClass = analyzeDecorators(symbol, decorators, this.handlers);
if (analyzedClass !== null && analyzedClass.diagnostics !== undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class ModuleWithProvidersAnalyzer {
let dtsFn: ts.Declaration|null = null;
const containerClass = fn.container && this.host.getClassSymbol(fn.container);
if (containerClass) {
const dtsClass = this.host.getDtsDeclaration(containerClass.valueDeclaration);
const dtsClass = this.host.getDtsDeclaration(containerClass.declaration.valueDeclaration);
// Get the declaration of the matching static method
dtsFn = dtsClass && ts.isClassDeclaration(dtsClass) ?
dtsClass.members
Expand Down
9 changes: 5 additions & 4 deletions packages/compiler-cli/ngcc/src/analysis/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import * as ts from 'typescript';

import {isFatalDiagnosticError} from '../../../src/ngtsc/diagnostics';
import {AbsoluteFsPath, absoluteFromSourceFile, relative} from '../../../src/ngtsc/file_system';
import {ClassSymbol, Decorator} from '../../../src/ngtsc/reflection';
import {Decorator} from '../../../src/ngtsc/reflection';
import {DecoratorHandler, DetectResult, HandlerPrecedence} from '../../../src/ngtsc/transform';
import {NgccClassSymbol} from '../host/ngcc_host';

import {AnalyzedClass, MatchingHandler} from './types';

Expand All @@ -19,9 +20,9 @@ export function isWithinPackage(packagePath: AbsoluteFsPath, sourceFile: ts.Sour
}

export function analyzeDecorators(
symbol: ClassSymbol, decorators: Decorator[] | null,
classSymbol: NgccClassSymbol, decorators: Decorator[] | null,
handlers: DecoratorHandler<any, any>[]): AnalyzedClass|null {
const declaration = symbol.valueDeclaration;
const declaration = classSymbol.declaration.valueDeclaration;
const matchingHandlers = handlers
.map(handler => {
const detected = handler.detect(declaration, decorators);
Expand Down Expand Up @@ -77,7 +78,7 @@ export function analyzeDecorators(
}
}
return {
name: symbol.name,
name: classSymbol.name,
declaration,
decorators,
matches,
Expand Down
9 changes: 5 additions & 4 deletions packages/compiler-cli/ngcc/src/host/commonjs_host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@

import * as ts from 'typescript';
import {absoluteFrom} from '../../../src/ngtsc/file_system';
import {ClassSymbol, Declaration, Import} from '../../../src/ngtsc/reflection';
import {Declaration, Import} from '../../../src/ngtsc/reflection';
import {Logger} from '../logging/logger';
import {BundleProgram} from '../packages/bundle_program';
import {isDefined} from '../utils';

import {Esm5ReflectionHost} from './esm5_host';
import {NgccClassSymbol} from './ngcc_host';

export class CommonJsReflectionHost extends Esm5ReflectionHost {
protected commonJsExports = new Map<ts.SourceFile, Map<string, Declaration>|null>();
Expand Down Expand Up @@ -57,13 +58,13 @@ export class CommonJsReflectionHost extends Esm5ReflectionHost {
* @param helperName the name of the helper (e.g. `__decorate`) whose calls we are interested in.
* @returns an array of nodes of calls to the helper with the given name.
*/
protected getHelperCallsForClass(classSymbol: ClassSymbol, helperName: string):
protected getHelperCallsForClass(classSymbol: NgccClassSymbol, helperName: string):
ts.CallExpression[] {
const esm5HelperCalls = super.getHelperCallsForClass(classSymbol, helperName);
if (esm5HelperCalls.length > 0) {
return esm5HelperCalls;
} else {
const sourceFile = classSymbol.valueDeclaration.getSourceFile();
const sourceFile = classSymbol.declaration.valueDeclaration.getSourceFile();
return this.getTopLevelHelperCalls(sourceFile, helperName);
}
}
Expand Down Expand Up @@ -244,4 +245,4 @@ function getOrDefault<K, V>(map: Map<K, V>, key: K, factory: (key: K) => V): V {
map.set(key, factory(key));
}
return map.get(key) !;
}
}
Loading