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

Function parseLoadingBlock

packages/compiler/src/render3/r3_deferred_blocks.ts:201–249  ·  view source on GitHub ↗
(ast: html.Block, visitor: html.Visitor)

Source from the content-addressed store, hash-verified

199}
200
201function parseLoadingBlock(ast: html.Block, visitor: html.Visitor): t.DeferredBlockLoading {
202 let afterTime: number | null = null;
203 let minimumTime: number | null = null;
204
205 for (const param of ast.parameters) {
206 if (AFTER_PARAMETER_PATTERN.test(param.expression)) {
207 if (afterTime != null) {
208 throw new Error(`@loading block can only have one "after" parameter`);
209 }
210
211 const parsedTime = parseDeferredTime(
212 param.expression.slice(getTriggerParametersStart(param.expression)),
213 );
214
215 if (parsedTime === null) {
216 throw new Error(`Could not parse time value of parameter "after"`);
217 }
218
219 afterTime = parsedTime;
220 } else if (MINIMUM_PARAMETER_PATTERN.test(param.expression)) {
221 if (minimumTime != null) {
222 throw new Error(`@loading block can only have one "minimum" parameter`);
223 }
224
225 const parsedTime = parseDeferredTime(
226 param.expression.slice(getTriggerParametersStart(param.expression)),
227 );
228
229 if (parsedTime === null) {
230 throw new Error(`Could not parse time value of parameter "minimum"`);
231 }
232
233 minimumTime = parsedTime;
234 } else {
235 throw new Error(`Unrecognized parameter in @loading block: "${param.expression}"`);
236 }
237 }
238
239 return new t.DeferredBlockLoading(
240 html.visitAll(visitor, ast.children, ast.children),
241 afterTime,
242 minimumTime,
243 ast.nameSpan,
244 ast.sourceSpan,
245 ast.startSourceSpan,
246 ast.endSourceSpan,
247 ast.i18n,
248 );
249}
250
251function parseErrorBlock(ast: html.Block, visitor: html.Visitor): t.DeferredBlockError {
252 if (ast.parameters.length > 0) {

Callers 1

parseConnectedBlocksFunction · 0.85

Calls 4

parseDeferredTimeFunction · 0.90
testMethod · 0.45
visitAllMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…