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

Function mergeTextTokens

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

Source from the content-addressed store, hash-verified

1378}
1379
1380function mergeTextTokens(srcTokens: Token[]): Token[] {
1381 const dstTokens: Token[] = [];
1382 let lastDstToken: Token | undefined = undefined;
1383 for (let i = 0; i < srcTokens.length; i++) {
1384 const token = srcTokens[i];
1385 if (
1386 (lastDstToken && lastDstToken.type === TokenType.TEXT && token.type === TokenType.TEXT) ||
1387 (lastDstToken &&
1388 lastDstToken.type === TokenType.ATTR_VALUE_TEXT &&
1389 token.type === TokenType.ATTR_VALUE_TEXT)
1390 ) {
1391 lastDstToken.parts[0]! += token.parts[0];
1392 lastDstToken.sourceSpan.end = token.sourceSpan.end;
1393 } else {
1394 lastDstToken = token;
1395 dstTokens.push(lastDstToken);
1396 }
1397 }
1398
1399 return dstTokens;
1400}
1401
1402/**
1403 * 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