MCPcopy Create free account
hub / github.com/angular/angular / parseLoadingBlock

Function parseLoadingBlock

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

Source from the content-addressed store, hash-verified

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

Callers 1

parseConnectedBlocksFunction · 0.85

Calls 5

parseDeferredTimeFunction · 0.90
sliceMethod · 0.65
testMethod · 0.45
visitAllMethod · 0.45

Tested by

no test coverage detected