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

Method _consumeBlockStart

packages/compiler/src/ml_parser/lexer.ts:314–359  ·  view source on GitHub ↗
(start: CharacterCursor)

Source from the content-addressed store, hash-verified

312 }
313
314 private _consumeBlockStart(start: CharacterCursor) {
315 this._requireCharCode(chars.$AT);
316 this._beginToken(TokenType.BLOCK_OPEN_START, start);
317 const startToken = this._endToken([this._getBlockName()]);
318
319 if (this._cursor.peek() === chars.$LPAREN) {
320 // Advance past the opening paren.
321 this._cursor.advance();
322 // Capture the parameters.
323 this._consumeBlockParameters();
324 // Allow spaces before the closing paren.
325 this._attemptCharCodeUntilFn(isNotWhitespace);
326
327 if (this._attemptCharCode(chars.$RPAREN)) {
328 // Allow spaces after the paren.
329 this._attemptCharCodeUntilFn(isNotWhitespace);
330 } else {
331 startToken.type = TokenType.INCOMPLETE_BLOCK_OPEN;
332 return;
333 }
334 }
335
336 if (startToken.parts[0] === 'default never' && this._attemptCharCode(chars.$SEMICOLON)) {
337 this._beginToken(TokenType.BLOCK_OPEN_END);
338 this._endToken([]);
339 this._beginToken(TokenType.BLOCK_CLOSE);
340 this._endToken([]);
341 return;
342 }
343
344 if (this._attemptCharCode(chars.$LBRACE)) {
345 this._beginToken(TokenType.BLOCK_OPEN_END);
346 this._endToken([]);
347 } else if (
348 this._isBlockStart() &&
349 (startToken.parts[0] === 'case' || startToken.parts[0] === 'default')
350 ) {
351 // We only allow @case statements to be consecutive without a block in between.
352 this._beginToken(TokenType.BLOCK_OPEN_END);
353 this._endToken([]);
354 this._beginToken(TokenType.BLOCK_CLOSE);
355 this._endToken([]);
356 } else {
357 startToken.type = TokenType.INCOMPLETE_BLOCK_OPEN;
358 }
359 }
360
361 private _consumeBlockEnd(start: CharacterCursor) {
362 this._beginToken(TokenType.BLOCK_CLOSE, start);

Callers 1

tokenizeMethod · 0.95

Calls 10

_requireCharCodeMethod · 0.95
_beginTokenMethod · 0.95
_endTokenMethod · 0.95
_getBlockNameMethod · 0.95
_attemptCharCodeMethod · 0.95
_isBlockStartMethod · 0.95
peekMethod · 0.65
advanceMethod · 0.65

Tested by

no test coverage detected