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

Method _consumeLetDeclaration

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

Source from the content-addressed store, hash-verified

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