refactor(ivy): ngcc - abstract how module statements are found (#25445)
This will be important for UMD support. PR Close #25445
This commit is contained in:
parent
989bfd2e97
commit
48b77459ef
|
@ -312,7 +312,7 @@ export class Esm2015ReflectionHost extends TypeScriptReflectionHost implements N
|
||||||
*/
|
*/
|
||||||
findDecoratedClasses(sourceFile: ts.SourceFile): DecoratedClass[] {
|
findDecoratedClasses(sourceFile: ts.SourceFile): DecoratedClass[] {
|
||||||
const classes: DecoratedClass[] = [];
|
const classes: DecoratedClass[] = [];
|
||||||
sourceFile.statements.map(statement => {
|
this.getModuleStatements(sourceFile).forEach(statement => {
|
||||||
if (ts.isVariableStatement(statement)) {
|
if (ts.isVariableStatement(statement)) {
|
||||||
statement.declarationList.declarations.forEach(declaration => {
|
statement.declarationList.declarations.forEach(declaration => {
|
||||||
const decoratedClass = this.getDecoratedClassFromSymbol(this.getClassSymbol(declaration));
|
const decoratedClass = this.getDecoratedClassFromSymbol(this.getClassSymbol(declaration));
|
||||||
|
@ -474,6 +474,16 @@ export class Esm2015ReflectionHost extends TypeScriptReflectionHost implements N
|
||||||
this.aliasedClassDeclarations.set(aliasedDeclaration.node, declaration.name);
|
this.aliasedClassDeclarations.set(aliasedDeclaration.node, declaration.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get the top level statements for a module.
|
||||||
|
*
|
||||||
|
* In ES5 and ES2015 this is just the top level statements of the file.
|
||||||
|
* @param sourceFile The module whose statements we want.
|
||||||
|
* @returns An array of top level statements for the given module.
|
||||||
|
*/
|
||||||
|
protected getModuleStatements(sourceFile: ts.SourceFile): ts.Statement[] {
|
||||||
|
return Array.from(sourceFile.statements);
|
||||||
|
}
|
||||||
|
|
||||||
protected getDecoratorsOfSymbol(symbol: ClassSymbol): Decorator[]|null {
|
protected getDecoratorsOfSymbol(symbol: ClassSymbol): Decorator[]|null {
|
||||||
const decoratorsProperty = this.getStaticProperty(symbol, DECORATORS);
|
const decoratorsProperty = this.getStaticProperty(symbol, DECORATORS);
|
||||||
if (decoratorsProperty) {
|
if (decoratorsProperty) {
|
||||||
|
|
Loading…
Reference in New Issue