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

Function mergeTextTokens

packages/compiler/src/ml_parser/lexer.ts:1547–1567  ·  view source on GitHub ↗
(srcTokens: Token[])

Source from the content-addressed store, hash-verified

1545}
1546
1547function mergeTextTokens(srcTokens: Token[]): Token[] {
1548 const dstTokens: Token[] = [];
1549 let lastDstToken: Token | undefined = undefined;
1550 for (let i = 0; i < srcTokens.length; i++) {
1551 const token = srcTokens[i];
1552 if (
1553 (lastDstToken && lastDstToken.type === TokenType.TEXT && token.type === TokenType.TEXT) ||
1554 (lastDstToken &&
1555 lastDstToken.type === TokenType.ATTR_VALUE_TEXT &&
1556 token.type === TokenType.ATTR_VALUE_TEXT)
1557 ) {
1558 lastDstToken.parts[0]! += token.parts[0];
1559 lastDstToken.sourceSpan.end = token.sourceSpan.end;
1560 } else {
1561 lastDstToken = token;
1562 dstTokens.push(lastDstToken);
1563 }
1564 }
1565
1566 return dstTokens;
1567}
1568
1569/**
1570 * The _Tokenizer uses objects of this type to move through the input text,

Callers 1

tokenizeFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected