(nodes, parent, parentStartLine, parentDynamicIndentation)
| 147528 | return inheritedIndentation; |
| 147529 | } |
| 147530 | function processChildNodes(nodes, parent, parentStartLine, parentDynamicIndentation) { |
| 147531 | ts.Debug.assert(ts.isNodeArray(nodes)); |
| 147532 | var listStartToken = getOpenTokenForList(parent, nodes); |
| 147533 | var listDynamicIndentation = parentDynamicIndentation; |
| 147534 | var startLine = parentStartLine; |
| 147535 | // node range is outside the target range - do not dive inside |
| 147536 | if (!ts.rangeOverlapsWithStartEnd(originalRange, nodes.pos, nodes.end)) { |
| 147537 | if (nodes.end < originalRange.pos) { |
| 147538 | formattingScanner.skipToEndOf(nodes); |
| 147539 | } |
| 147540 | return; |
| 147541 | } |
| 147542 | if (listStartToken !== 0 /* SyntaxKind.Unknown */) { |
| 147543 | // introduce a new indentation scope for lists (including list start and end tokens) |
| 147544 | while (formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { |
| 147545 | var tokenInfo = formattingScanner.readTokenInfo(parent); |
| 147546 | if (tokenInfo.token.end > nodes.pos) { |
| 147547 | // stop when formatting scanner moves past the beginning of node list |
| 147548 | break; |
| 147549 | } |
| 147550 | else if (tokenInfo.token.kind === listStartToken) { |
| 147551 | // consume list start token |
| 147552 | startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; |
| 147553 | consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent); |
| 147554 | var indentationOnListStartToken = void 0; |
| 147555 | if (indentationOnLastIndentedLine !== -1 /* Constants.Unknown */) { |
| 147556 | // scanner just processed list start token so consider last indentation as list indentation |
| 147557 | // function foo(): { // last indentation was 0, list item will be indented based on this value |
| 147558 | // foo: number; |
| 147559 | // }: {}; |
| 147560 | indentationOnListStartToken = indentationOnLastIndentedLine; |
| 147561 | } |
| 147562 | else { |
| 147563 | var startLinePosition = ts.getLineStartPositionForPosition(tokenInfo.token.pos, sourceFile); |
| 147564 | indentationOnListStartToken = formatting.SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, tokenInfo.token.pos, sourceFile, options); |
| 147565 | } |
| 147566 | listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentationOnListStartToken, options.indentSize); // TODO: GH#18217 |
| 147567 | } |
| 147568 | else { |
| 147569 | // consume any tokens that precede the list as child elements of 'node' using its indentation scope |
| 147570 | consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent); |
| 147571 | } |
| 147572 | } |
| 147573 | } |
| 147574 | var inheritedIndentation = -1 /* Constants.Unknown */; |
| 147575 | for (var i = 0; i < nodes.length; i++) { |
| 147576 | var child = nodes[i]; |
| 147577 | inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListItem*/ true, /*isFirstListItem*/ i === 0); |
| 147578 | } |
| 147579 | var listEndToken = getCloseTokenForOpenToken(listStartToken); |
| 147580 | if (listEndToken !== 0 /* SyntaxKind.Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { |
| 147581 | var tokenInfo = formattingScanner.readTokenInfo(parent); |
| 147582 | if (tokenInfo.token.kind === 27 /* SyntaxKind.CommaToken */ && ts.isCallLikeExpression(parent)) { |
| 147583 | var commaTokenLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; |
| 147584 | if (startLine !== commaTokenLine) { |
| 147585 | formattingScanner.advance(); |
| 147586 | tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined; |
| 147587 | } |
no test coverage detected