MCPcopy Index your code
hub / github.com/angular/angular / span

Method span

packages/compiler/src/expression_parser/parser.ts:654–673  ·  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

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