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

Method _consumeLetDeclaration

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

Source from the content-addressed store, hash-verified

409 }
410
411 private _consumeLetDeclaration(start: CharacterCursor) {
412 this._requireStr('@let');
413 this._beginToken(TokenType.LET_START, start);
414
415 // Require at least one white space after the `@let`.
416 if (chars.isWhitespace(this._cursor.peek())) {
417 this._attemptCharCodeUntilFn(isNotWhitespace);
418 } else {
419 const token = this._endToken([this._cursor.getChars(start)]);
420 token.type = TokenType.INCOMPLETE_LET;
421 return;
422 }
423
424 const startToken = this._endToken([this._getLetDeclarationName()]);
425
426 // Skip over white space before the equals character.
427 this._attemptCharCodeUntilFn(isNotWhitespace);
428
429 // Expect an equals sign.
430 if (!this._attemptCharCode(chars.$EQ)) {
431 startToken.type = TokenType.INCOMPLETE_LET;
432 return;
433 }
434
435 // Skip spaces after the equals.
436 this._attemptCharCodeUntilFn((code) => isNotWhitespace(code) && !chars.isNewLine(code));
437 this._consumeLetDeclarationValue();
438
439 // Terminate the `@let` with a semicolon.
440 const endChar = this._cursor.peek();
441 if (endChar === chars.$SEMICOLON) {
442 this._beginToken(TokenType.LET_END);
443 this._cursor.advance();
444 this._endToken([]);
445 } else {
446 startToken.type = TokenType.INCOMPLETE_LET;
447 startToken.sourceSpan = this._cursor.getSpan(start);
448 }
449 }
450
451 private _getLetDeclarationName(): string {
452 const nameCursor = this._cursor.clone();

Callers 1

tokenizeMethod · 0.95

Calls 12

_requireStrMethod · 0.95
_beginTokenMethod · 0.95
_endTokenMethod · 0.95
_attemptCharCodeMethod · 0.95
isNotWhitespaceFunction · 0.85
peekMethod · 0.65
getCharsMethod · 0.65
advanceMethod · 0.65
getSpanMethod · 0.65

Tested by

no test coverage detected