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

Function mergeTextTokens

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

Source from the content-addressed store, hash-verified

1560}
1561
1562function mergeTextTokens(srcTokens: Token[]): Token[] {
1563 const dstTokens: Token[] = [];
1564 let lastDstToken: Token | undefined = undefined;
1565 for (let i = 0; i < srcTokens.length; i++) {
1566 const token = srcTokens[i];
1567 if (
1568 (lastDstToken && lastDstToken.type === TokenType.TEXT && token.type === TokenType.TEXT) ||
1569 (lastDstToken &&
1570 lastDstToken.type === TokenType.ATTR_VALUE_TEXT &&
1571 token.type === TokenType.ATTR_VALUE_TEXT)
1572 ) {
1573 lastDstToken.parts[0]! += token.parts[0];
1574 lastDstToken.sourceSpan.end = token.sourceSpan.end;
1575 } else {
1576 lastDstToken = token;
1577 dstTokens.push(lastDstToken);
1578 }
1579 }
1580
1581 return dstTokens;
1582}
1583
1584/**
1585 * 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