refactor(compiler): remove unused constructor query support
This commit is contained in:
parent
f6710fefeb
commit
234c5599f1
|
@ -105,14 +105,10 @@ 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}: {
|
||||
constructor({isAttribute, isSelf, isHost, isSkipSelf, isOptional, isValue, token, value}: {
|
||||
isAttribute?: boolean,
|
||||
isSelf?: boolean,
|
||||
isHost?: boolean,
|
||||
|
@ -130,8 +126,6 @@ export class CompileDiDependencyMetadata {
|
|||
this.isSkipSelf = !!isSkipSelf;
|
||||
this.isOptional = !!isOptional;
|
||||
this.isValue = !!isValue;
|
||||
this.query = query;
|
||||
this.viewQuery = viewQuery;
|
||||
this.token = token;
|
||||
this.value = value;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
});
|
||||
|
||||
|
|
|
@ -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<any, CompileQ
|
|||
if (isPresent(component.viewQueries)) {
|
||||
component.viewQueries.forEach((query) => _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;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,6 @@ export class CompileElement extends CompileNode {
|
|||
|
||||
private _queryCount = 0;
|
||||
private _queries = new Map<any, CompileQuery[]>();
|
||||
private _componentConstructorViewQueryLists: o.Expression[] = [];
|
||||
|
||||
public contentNodesByNgContentIndex: Array<CompileViewRootNode>[] = 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) {
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -22,11 +22,10 @@ import {ViewType} from './view_type';
|
|||
* that is needed for later instantiations.
|
||||
*/
|
||||
export class AppElement {
|
||||
public nestedViews: AppView<any>[] = null;
|
||||
public componentView: AppView<any> = null;
|
||||
public nestedViews: AppView<any>[];
|
||||
public componentView: AppView<any>;
|
||||
|
||||
public component: any;
|
||||
public componentConstructorViewQueries: QueryList<any>[];
|
||||
|
||||
constructor(
|
||||
public index: number, public parentIndex: number, public parentView: AppView<any>,
|
||||
|
@ -36,10 +35,8 @@ export class AppElement {
|
|||
|
||||
get vcRef(): ViewContainerRef_ { return new ViewContainerRef_(this); }
|
||||
|
||||
initComponent(
|
||||
component: any, componentConstructorViewQueries: QueryList<any>[], view: AppView<any>) {
|
||||
initComponent(component: any, view: AppView<any>) {
|
||||
this.component = component;
|
||||
this.componentConstructorViewQueries = componentConstructorViewQueries;
|
||||
this.componentView = view;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class _View_TreeComponent_Host0 extends import1.AppView<any> {
|
|||
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, [], <any>this._TreeComponent_0_4);
|
||||
this._vc_0.initComponent(this._TreeComponent_0_4.context, <any>this._TreeComponent_0_4);
|
||||
this.init([].concat([this._el_0]), [this._el_0], []);
|
||||
return this._vc_0;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ class _View_TreeRootComponent_Host0 extends import1.AppView<any> {
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue