MCPcopy
hub / github.com/angular/angular / _consumeLetDeclaration

Method _consumeLetDeclaration

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

Source from the content-addressed store, hash-verified

392 }
393
394 private _consumeLetDeclaration(start: CharacterCursor) {
395 this._requireStr('@let');
396 this._beginToken(TokenType.LET_START, start);
397
398 // Require at least one white space after the `@let`.
399 if (chars.isWhitespace(this._cursor.peek())) {
400 this._attemptCharCodeUntilFn(isNotWhitespace);
401 } else {
402 const token = this._endToken([this._cursor.getChars(start)]);
403 token.type = TokenType.INCOMPLETE_LET;
404 return;
405 }
406
407 const startToken = this._endToken([this._getLetDeclarationName()]);
408
409 // Skip over white space before the equals character.
410 this._attemptCharCodeUntilFn(isNotWhitespace);
411
412 // Expect an equals sign.
413 if (!this._attemptCharCode(chars.$EQ)) {
414 startToken.type = TokenType.INCOMPLETE_LET;
415 return;
416 }
417
418 // Skip spaces after the equals.
419 this._attemptCharCodeUntilFn((code) => isNotWhitespace(code) && !chars.isNewLine(code));
420 this._consumeLetDeclarationValue();
421
422 // Terminate the `@let` with a semicolon.
423 const endChar = this._cursor.peek();
424 if (endChar === chars.$SEMICOLON) {
425 this._beginToken(TokenType.LET_END);
426 this._cursor.advance();
427 this._endToken([]);
428 } else {
429 startToken.type = TokenType.INCOMPLETE_LET;
430 startToken.sourceSpan = this._cursor.getSpan(start);
431 }
432 }
433
434 private _getLetDeclarationName(): string {
435 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