refactor(ivy): rename query-related functions for clarity (#30587)

PR Close #30587
This commit is contained in:
Pawel Kozlowski 2019-05-21 12:15:38 +02:00 committed by Jason Aden
parent b613f90146
commit 66f269c077
2 changed files with 10 additions and 8 deletions

View File

@ -97,9 +97,9 @@ export class LQueries_ implements LQueries {
track<T>(queryList: QueryList<T>, predicate: Type<T>|string[], descend?: boolean, read?: Type<T>): track<T>(queryList: QueryList<T>, predicate: Type<T>|string[], descend?: boolean, read?: Type<T>):
void { void {
if (descend) { if (descend) {
this.deep = createQuery(this.deep, queryList, predicate, read != null ? read : null); this.deep = createLQuery(this.deep, queryList, predicate, read != null ? read : null);
} else { } else {
this.shallow = createQuery(this.shallow, queryList, predicate, read != null ? read : null); this.shallow = createLQuery(this.shallow, queryList, predicate, read != null ? read : null);
} }
} }
@ -346,7 +346,7 @@ function createPredicate<T>(predicate: Type<T>| string[], read: Type<T>| null):
}; };
} }
function createQuery<T>( function createLQuery<T>(
previous: LQuery<any>| null, queryList: QueryList<T>, predicate: Type<T>| string[], previous: LQuery<any>| null, queryList: QueryList<T>, predicate: Type<T>| string[],
read: Type<T>| null): LQuery<T> { read: Type<T>| null): LQuery<T> {
return { return {
@ -361,14 +361,14 @@ function createQuery<T>(
type QueryList_<T> = QueryList<T>& {_valuesTree: any[], _static: boolean}; type QueryList_<T> = QueryList<T>& {_valuesTree: any[], _static: boolean};
/** /**
* Creates and returns a QueryList. * Creates a QueryList and stores it in LView's collection of active queries (LQueries).
* *
* @param predicate The type for which the query will search * @param predicate The type for which the query will search
* @param descend Whether or not to descend into children * @param descend Whether or not to descend into children
* @param read What to save in the query * @param read What to save in the query
* @returns QueryList<T> * @returns QueryList<T>
*/ */
function query<T>( function createQueryListInLView<T>(
// TODO: "read" should be an AbstractType (FW-486) // TODO: "read" should be an AbstractType (FW-486)
lView: LView, predicate: Type<any>| string[], descend: boolean, read: any, lView: LView, predicate: Type<any>| string[], descend: boolean, read: any,
isStatic: boolean): QueryList<T> { isStatic: boolean): QueryList<T> {
@ -447,7 +447,8 @@ function viewQueryInternal<T>(
tView.expandoStartIndex++; tView.expandoStartIndex++;
} }
const index = getCurrentQueryIndex(); const index = getCurrentQueryIndex();
const queryList: QueryList<T> = query<T>(lView, predicate, descend, read, isStatic); const queryList: QueryList<T> =
createQueryListInLView<T>(lView, predicate, descend, read, isStatic);
store(index - HEADER_OFFSET, queryList); store(index - HEADER_OFFSET, queryList);
setCurrentQueryIndex(index + 1); setCurrentQueryIndex(index + 1);
return queryList; return queryList;
@ -490,7 +491,8 @@ function contentQueryInternal<T>(
descend: boolean, descend: boolean,
// TODO(FW-486): "read" should be an AbstractType // TODO(FW-486): "read" should be an AbstractType
read: any, isStatic: boolean): QueryList<T> { read: any, isStatic: boolean): QueryList<T> {
const contentQuery: QueryList<T> = query<T>(lView, predicate, descend, read, isStatic); const contentQuery: QueryList<T> =
createQueryListInLView<T>(lView, predicate, descend, read, isStatic);
(lView[CONTENT_QUERIES] || (lView[CONTENT_QUERIES] = [])).push(contentQuery); (lView[CONTENT_QUERIES] || (lView[CONTENT_QUERIES] = [])).push(contentQuery);
if (tView.firstTemplatePass) { if (tView.firstTemplatePass) {
const tViewContentQueries = tView.contentQueries || (tView.contentQueries = []); const tViewContentQueries = tView.contentQueries || (tView.contentQueries = []);

View File

@ -12,7 +12,7 @@ import {EventEmitter} from '../..';
import {AttributeMarker, detectChanges, ɵɵProvidersFeature, ɵɵdefineComponent, ɵɵdefineDirective} from '../../src/render3/index'; import {AttributeMarker, detectChanges, ɵɵProvidersFeature, ɵɵdefineComponent, ɵɵdefineDirective} from '../../src/render3/index';
import {ɵɵcontainer, ɵɵcontainerRefreshEnd, ɵɵcontainerRefreshStart, ɵɵdirectiveInject, ɵɵelement, ɵɵelementContainerEnd, ɵɵelementContainerStart, ɵɵelementEnd, ɵɵelementStart, ɵɵembeddedViewEnd, ɵɵembeddedViewStart, ɵɵload, ɵɵtemplate, ɵɵtext} from '../../src/render3/instructions/all'; import {ɵɵcontainer, ɵɵcontainerRefreshEnd, ɵɵcontainerRefreshStart, ɵɵdirectiveInject, ɵɵelement, ɵɵelementContainerEnd, ɵɵelementContainerStart, ɵɵelementEnd, ɵɵelementStart, ɵɵembeddedViewEnd, ɵɵembeddedViewStart, ɵɵload, ɵɵtemplate, ɵɵtext} from '../../src/render3/instructions/all';
import {RenderFlags} from '../../src/render3/interfaces/definition'; import {RenderFlags} from '../../src/render3/interfaces/definition';
import {query, ɵɵcontentQuery, ɵɵloadContentQuery, ɵɵloadViewQuery, ɵɵqueryRefresh, ɵɵviewQuery} from '../../src/render3/query'; import {ɵɵcontentQuery, ɵɵloadContentQuery, ɵɵloadViewQuery, ɵɵqueryRefresh, ɵɵviewQuery} from '../../src/render3/query';
import {getLView} from '../../src/render3/state'; import {getLView} from '../../src/render3/state';
import {getNativeByIndex} from '../../src/render3/util/view_utils'; import {getNativeByIndex} from '../../src/render3/util/view_utils';
import {ɵɵtemplateRefExtractor} from '../../src/render3/view_engine_compatibility_prebound'; import {ɵɵtemplateRefExtractor} from '../../src/render3/view_engine_compatibility_prebound';