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

Method _consumeLetDeclaration

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

Source from the content-addressed store, hash-verified

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