MCPcopy Index your code
hub / github.com/angular/angular / compileQuery

Function compileQuery

packages/compiler/src/render3/partial/directive.ts:174–204  ·  view source on GitHub ↗

* Compiles the metadata of a single query into its partial declaration form as declared * by `R3DeclareQueryMetadata`.

(query: R3QueryMetadata)

Source from the content-addressed store, hash-verified

172 * by `R3DeclareQueryMetadata`.
173 */
174function compileQuery(query: R3QueryMetadata): o.LiteralMapExpr {
175 const meta = new DefinitionMap<R3DeclareQueryMetadata>();
176 meta.set('propertyName', o.literal(query.propertyName));
177 if (query.first) {
178 meta.set('first', o.literal(true));
179 }
180 meta.set(
181 'predicate',
182 Array.isArray(query.predicate)
183 ? asLiteral(query.predicate)
184 : convertFromMaybeForwardRefExpression(query.predicate),
185 );
186 if (!query.emitDistinctChangesOnly) {
187 // `emitDistinctChangesOnly` is special because we expect it to be `true`.
188 // Therefore we explicitly emit the field, and explicitly place it only when it's `false`.
189 meta.set('emitDistinctChangesOnly', o.literal(false));
190 } else {
191 // The linker will assume that an absent `emitDistinctChangesOnly` flag is by default `true`.
192 }
193 if (query.descendants) {
194 meta.set('descendants', o.literal(true));
195 }
196 meta.set('read', query.read);
197 if (query.static) {
198 meta.set('static', o.literal(true));
199 }
200 if (query.isSignal) {
201 meta.set('isSignal', o.literal(true));
202 }
203 return meta.toLiteralMap();
204}
205
206/**
207 * Compiles the host metadata into its partial declaration form as declared

Callers

nothing calls this directly

Calls 5

setMethod · 0.95
toLiteralMapMethod · 0.95
asLiteralFunction · 0.90
isArrayMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…