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

Method span

packages/compiler/src/expression_parser/parser.ts:650–669  ·  view source on GitHub ↗

* Retrieve a `ParseSpan` from `start` to the current position (or to `artificialEndIndex` if * provided). * * @param start Position from which the `ParseSpan` will start. * @param artificialEndIndex Optional ending index to be used if provided (and if greater than the * natural en

(start: number, artificialEndIndex?: number)

Source from the content-addressed store, hash-verified

648 * natural ending index)
649 */
650 private span(start: number, artificialEndIndex?: number): ParseSpan {
651 let endIndex = this.currentEndIndex;
652 if (artificialEndIndex !== undefined && artificialEndIndex > this.currentEndIndex) {
653 endIndex = artificialEndIndex;
654 }
655
656 // In some unusual parsing scenarios (like when certain tokens are missing and an `EmptyExpr` is
657 // being created), the current token may already be advanced beyond the `currentEndIndex`. This
658 // appears to be a deep-seated parser bug.
659 //
660 // As a workaround for now, swap the start and end indices to ensure a valid `ParseSpan`.
661 // TODO(alxhub): fix the bug upstream in the parser state, and remove this workaround.
662 if (start > endIndex) {
663 const tmp = endIndex;
664 endIndex = start;
665 start = tmp;
666 }
667
668 return new ParseSpan(start, endIndex);
669 }
670
671 private sourceSpan(start: number, artificialEndIndex?: number): AbsoluteSourceSpan {
672 const serial = `${start}@${this.inputIndex}:${artificialEndIndex}`;

Callers 15

sourceSpanMethod · 0.95
parseChainMethod · 0.95
parsePipeMethod · 0.95
parseConditionalMethod · 0.95
parseLogicalOrMethod · 0.95
parseLogicalAndMethod · 0.95
parseEqualityMethod · 0.95
parseRelationalMethod · 0.95
parseAdditiveMethod · 0.95
parseMultiplicativeMethod · 0.95
parseExponentiationMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected