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

Method _consumeLetDeclaration

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

Source from the content-addressed store, hash-verified

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