From 234c5599f10c33e743594b556b63bc6fdd87e7eb Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Mon, 31 Oct 2016 15:46:24 -0700 Subject: [PATCH] refactor(compiler): remove unused constructor query support --- .../@angular/compiler/src/compile_metadata.ts | 30 ++++++++----------- .../compiler/src/metadata_resolver.ts | 10 ------- .../compiler/src/provider_analyzer.ts | 13 -------- .../src/view_compiler/compile_element.ts | 24 +-------------- .../src/view_compiler/compile_view.ts | 10 ------- .../src/view_compiler/view_builder.ts | 2 +- modules/@angular/core/src/linker/element.ts | 9 ++---- .../src/tree/ng2_ftl/tree_host.ngfactory.ts | 2 +- .../ng2_static_ftl/tree_root.ngfactory.ts | 2 +- 9 files changed, 19 insertions(+), 83 deletions(-) diff --git a/modules/@angular/compiler/src/compile_metadata.ts b/modules/@angular/compiler/src/compile_metadata.ts index 1699b35b0e..05669740a1 100644 --- a/modules/@angular/compiler/src/compile_metadata.ts +++ b/modules/@angular/compiler/src/compile_metadata.ts @@ -105,33 +105,27 @@ export class CompileDiDependencyMetadata { isSkipSelf: boolean; isOptional: boolean; isValue: boolean; - query: CompileQueryMetadata; - viewQuery: CompileQueryMetadata; token: CompileTokenMetadata; value: any; - constructor( - {isAttribute, isSelf, isHost, isSkipSelf, isOptional, isValue, query, viewQuery, token, - value}: { - isAttribute?: boolean, - isSelf?: boolean, - isHost?: boolean, - isSkipSelf?: boolean, - isOptional?: boolean, - isValue?: boolean, - query?: CompileQueryMetadata, - viewQuery?: CompileQueryMetadata, - token?: CompileTokenMetadata, - value?: any - } = {}) { + constructor({isAttribute, isSelf, isHost, isSkipSelf, isOptional, isValue, token, value}: { + isAttribute?: boolean, + isSelf?: boolean, + isHost?: boolean, + isSkipSelf?: boolean, + isOptional?: boolean, + isValue?: boolean, + query?: CompileQueryMetadata, + viewQuery?: CompileQueryMetadata, + token?: CompileTokenMetadata, + value?: any + } = {}) { this.isAttribute = !!isAttribute; this.isSelf = !!isSelf; this.isHost = !!isHost; this.isSkipSelf = !!isSkipSelf; this.isOptional = !!isOptional; this.isValue = !!isValue; - this.query = query; - this.viewQuery = viewQuery; this.token = token; this.value = value; } diff --git a/modules/@angular/compiler/src/metadata_resolver.ts b/modules/@angular/compiler/src/metadata_resolver.ts index 52bdfac1e3..3c0c9e04c0 100644 --- a/modules/@angular/compiler/src/metadata_resolver.ts +++ b/modules/@angular/compiler/src/metadata_resolver.ts @@ -506,8 +506,6 @@ export class CompileMetadataResolver { let isSelf = false; let isSkipSelf = false; let isOptional = false; - let query: Query = null; - let viewQuery: Query = null; let token: any = null; if (Array.isArray(param)) { param.forEach((paramEntry) => { @@ -522,12 +520,6 @@ export class CompileMetadataResolver { } else if (paramEntry instanceof Attribute) { isAttribute = true; token = paramEntry.attributeName; - } else if (paramEntry instanceof Query) { - if (paramEntry.isViewQuery) { - viewQuery = paramEntry; - } else { - query = paramEntry; - } } else if (paramEntry instanceof Inject) { token = paramEntry.token; } else if (isValidType(paramEntry) && isBlank(token)) { @@ -548,8 +540,6 @@ export class CompileMetadataResolver { isSelf, isSkipSelf, isOptional, - query: query ? this.getQueryMetadata(query, null, typeOrFunc) : null, - viewQuery: viewQuery ? this.getQueryMetadata(viewQuery, null, typeOrFunc) : null, token: this.getTokenMetadata(token) }); diff --git a/modules/@angular/compiler/src/provider_analyzer.ts b/modules/@angular/compiler/src/provider_analyzer.ts index 64e3908e2e..49e9fb9a3d 100644 --- a/modules/@angular/compiler/src/provider_analyzer.ts +++ b/modules/@angular/compiler/src/provider_analyzer.ts @@ -197,9 +197,6 @@ export class ProviderElementContext { return new CompileDiDependencyMetadata( {isValue: true, value: attrValue == null ? null : attrValue}); } - if (isPresent(dep.query) || isPresent(dep.viewQuery)) { - return dep; - } if (isPresent(dep.token)) { // access builtints @@ -503,11 +500,6 @@ function _getViewQueries(component: CompileDirectiveMetadata): Map _addQueryToTokenMap(viewQueries, query)); } - component.type.diDeps.forEach((dep) => { - if (isPresent(dep.viewQuery)) { - _addQueryToTokenMap(viewQueries, dep.viewQuery); - } - }); return viewQueries; } @@ -518,11 +510,6 @@ function _getContentQueries(directives: CompileDirectiveMetadata[]): if (isPresent(directive.queries)) { directive.queries.forEach((query) => _addQueryToTokenMap(contentQueries, query)); } - directive.type.diDeps.forEach((dep) => { - if (isPresent(dep.query)) { - _addQueryToTokenMap(contentQueries, dep.query); - } - }); }); return contentQueries; } diff --git a/modules/@angular/compiler/src/view_compiler/compile_element.ts b/modules/@angular/compiler/src/view_compiler/compile_element.ts index b6f6d389e6..3407074c67 100644 --- a/modules/@angular/compiler/src/view_compiler/compile_element.ts +++ b/modules/@angular/compiler/src/view_compiler/compile_element.ts @@ -49,7 +49,6 @@ export class CompileElement extends CompileNode { private _queryCount = 0; private _queries = new Map(); - private _componentConstructorViewQueryLists: o.Expression[] = []; public contentNodesByNgContentIndex: Array[] = null; public embeddedView: CompileView; @@ -257,16 +256,9 @@ export class CompileElement extends CompileNode { }); if (isPresent(this.component)) { - var componentConstructorViewQueryList = isPresent(this.component) ? - o.literalArr(this._componentConstructorViewQueryLists) : - o.NULL_EXPR; var compExpr = isPresent(this.getComponent()) ? this.getComponent() : o.NULL_EXPR; this.view.createMethod.addStmt( - this.appElement - .callMethod( - 'initComponent', - [compExpr, componentConstructorViewQueryList, this._compViewExpr]) - .toStmt()); + this.appElement.callMethod('initComponent', [compExpr, this._compViewExpr]).toStmt()); } } @@ -342,20 +334,6 @@ export class CompileElement extends CompileNode { private _getLocalDependency( requestingProviderType: ProviderAstType, dep: CompileDiDependencyMetadata): o.Expression { var result: o.Expression = null; - // constructor content query - if (!result && isPresent(dep.query)) { - result = this._addQuery(dep.query, null).queryList; - } - - // constructor view query - if (!result && isPresent(dep.viewQuery)) { - result = createQueryList( - dep.viewQuery, null, - `_viewQuery_${dep.viewQuery.selectors[0].name}_${this.nodeIndex}_${this._componentConstructorViewQueryLists.length}`, - this.view); - this._componentConstructorViewQueryLists.push(result); - } - if (isPresent(dep.token)) { // access builtins with special visibility if (!result) { diff --git a/modules/@angular/compiler/src/view_compiler/compile_view.ts b/modules/@angular/compiler/src/view_compiler/compile_view.ts index 256d5dff61..863197ab42 100644 --- a/modules/@angular/compiler/src/view_compiler/compile_view.ts +++ b/modules/@angular/compiler/src/view_compiler/compile_view.ts @@ -121,16 +121,6 @@ export class CompileView implements NameResolver { var query = new CompileQuery(queryMeta, queryList, directiveInstance, this); addQueryToTokenMap(viewQueries, query); }); - var constructorViewQueryCount = 0; - this.component.type.diDeps.forEach((dep) => { - if (isPresent(dep.viewQuery)) { - var queryList = o.THIS_EXPR.prop('declarationAppElement') - .prop('componentConstructorViewQueries') - .key(o.literal(constructorViewQueryCount++)); - var query = new CompileQuery(dep.viewQuery, queryList, null, this); - addQueryToTokenMap(viewQueries, query); - } - }); } this.viewQueries = viewQueries; templateVariableBindings.forEach( diff --git a/modules/@angular/compiler/src/view_compiler/view_builder.ts b/modules/@angular/compiler/src/view_compiler/view_builder.ts index c5ab32ad42..0590c2bbc7 100644 --- a/modules/@angular/compiler/src/view_compiler/view_builder.ts +++ b/modules/@angular/compiler/src/view_compiler/view_builder.ts @@ -119,7 +119,7 @@ class ViewBuilderVisitor implements TemplateAstVisitor { 'createTemplateAnchor', [o.NULL_EXPR, o.NULL_EXPR])) .toStmt()); view.rootNodes.push( - new CompileViewRootNode(CompileViewRootNodeType.Node, o.THIS_EXPR.prop(fieldName))) + new CompileViewRootNode(CompileViewRootNodeType.Node, o.THIS_EXPR.prop(fieldName))); } return view.rootNodes[view.rootNodes.length - 1].expr; } diff --git a/modules/@angular/core/src/linker/element.ts b/modules/@angular/core/src/linker/element.ts index 173f6e3c3f..9087775fb4 100644 --- a/modules/@angular/core/src/linker/element.ts +++ b/modules/@angular/core/src/linker/element.ts @@ -22,11 +22,10 @@ import {ViewType} from './view_type'; * that is needed for later instantiations. */ export class AppElement { - public nestedViews: AppView[] = null; - public componentView: AppView = null; + public nestedViews: AppView[]; + public componentView: AppView; public component: any; - public componentConstructorViewQueries: QueryList[]; constructor( public index: number, public parentIndex: number, public parentView: AppView, @@ -36,10 +35,8 @@ export class AppElement { get vcRef(): ViewContainerRef_ { return new ViewContainerRef_(this); } - initComponent( - component: any, componentConstructorViewQueries: QueryList[], view: AppView) { + initComponent(component: any, view: AppView) { this.component = component; - this.componentConstructorViewQueries = componentConstructorViewQueries; this.componentView = view; } diff --git a/modules/benchmarks/src/tree/ng2_ftl/tree_host.ngfactory.ts b/modules/benchmarks/src/tree/ng2_ftl/tree_host.ngfactory.ts index 235d71a43a..9fec4a1099 100644 --- a/modules/benchmarks/src/tree/ng2_ftl/tree_host.ngfactory.ts +++ b/modules/benchmarks/src/tree/ng2_ftl/tree_host.ngfactory.ts @@ -37,7 +37,7 @@ class _View_TreeComponent_Host0 extends import1.AppView { this.renderer, 'tree', import4.EMPTY_INLINE_ARRAY, rootSelector, (null as any)); this._vc_0 = new import2.AppElement(0, (null as any), this, this._el_0); this._TreeComponent_0_4 = new _View_TreeComponent0(this._el_0); - this._vc_0.initComponent(this._TreeComponent_0_4.context, [], this._TreeComponent_0_4); + this._vc_0.initComponent(this._TreeComponent_0_4.context, this._TreeComponent_0_4); this.init([].concat([this._el_0]), [this._el_0], []); return this._vc_0; } diff --git a/modules/benchmarks/src/tree/ng2_static_ftl/tree_root.ngfactory.ts b/modules/benchmarks/src/tree/ng2_static_ftl/tree_root.ngfactory.ts index 29764743d7..5e2f9abd8f 100644 --- a/modules/benchmarks/src/tree/ng2_static_ftl/tree_root.ngfactory.ts +++ b/modules/benchmarks/src/tree/ng2_static_ftl/tree_root.ngfactory.ts @@ -42,7 +42,7 @@ class _View_TreeRootComponent_Host0 extends import1.AppView { this._TreeRootComponent_0_4_View = viewFactory_TreeRootComponent0(this.viewUtils, this.injector(0), this._appEl_0); this._TreeRootComponent_0_4 = new import3.TreeRootComponent(); - this._appEl_0.initComponent(this._TreeRootComponent_0_4, [], this._TreeRootComponent_0_4_View); + this._appEl_0.initComponent(this._TreeRootComponent_0_4, this._TreeRootComponent_0_4_View); this._TreeRootComponent_0_4_View.create(this._TreeRootComponent_0_4, (null as any)); this.init([].concat([this._el_0]), [this._el_0], []); return this._appEl_0;