(node, contextNode, nodeStartLine, undecoratedNodeStartLine, indentation, delta)
| 147431 | } |
| 147432 | } |
| 147433 | function processNode(node, contextNode, nodeStartLine, undecoratedNodeStartLine, indentation, delta) { |
| 147434 | if (!ts.rangeOverlapsWithStartEnd(originalRange, node.getStart(sourceFile), node.getEnd())) { |
| 147435 | return; |
| 147436 | } |
| 147437 | var nodeDynamicIndentation = getDynamicIndentation(node, nodeStartLine, indentation, delta); |
| 147438 | // a useful observations when tracking context node |
| 147439 | // / |
| 147440 | // [a] |
| 147441 | // / | \ |
| 147442 | // [b] [c] [d] |
| 147443 | // node 'a' is a context node for nodes 'b', 'c', 'd' |
| 147444 | // except for the leftmost leaf token in [b] - in this case context node ('e') is located somewhere above 'a' |
| 147445 | // this rule can be applied recursively to child nodes of 'a'. |
| 147446 | // |
| 147447 | // context node is set to parent node value after processing every child node |
| 147448 | // context node is set to parent of the token after processing every token |
| 147449 | var childContextNode = contextNode; |
| 147450 | // if there are any tokens that logically belong to node and interleave child nodes |
| 147451 | // such tokens will be consumed in processChildNode for the child that follows them |
| 147452 | ts.forEachChild(node, function (child) { |
| 147453 | processChildNode(child, /*inheritedIndentation*/ -1 /* Constants.Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false); |
| 147454 | }, function (nodes) { |
| 147455 | processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); |
| 147456 | }); |
| 147457 | // proceed any tokens in the node that are located after child nodes |
| 147458 | while (formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { |
| 147459 | var tokenInfo = formattingScanner.readTokenInfo(node); |
| 147460 | if (tokenInfo.token.end > Math.min(node.end, originalRange.end)) { |
| 147461 | break; |
| 147462 | } |
| 147463 | consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); |
| 147464 | } |
| 147465 | function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { |
| 147466 | if (ts.nodeIsMissing(child)) { |
| 147467 | return inheritedIndentation; |
| 147468 | } |
| 147469 | var childStartPos = child.getStart(sourceFile); |
| 147470 | var childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line; |
| 147471 | var undecoratedChildStartLine = childStartLine; |
| 147472 | if (child.decorators) { |
| 147473 | undecoratedChildStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(child, sourceFile)).line; |
| 147474 | } |
| 147475 | // if child is a list item - try to get its indentation, only if parent is within the original range. |
| 147476 | var childIndentationAmount = -1 /* Constants.Unknown */; |
| 147477 | if (isListItem && ts.rangeContainsRange(originalRange, parent)) { |
| 147478 | childIndentationAmount = tryComputeIndentationForListItem(childStartPos, child.end, parentStartLine, originalRange, inheritedIndentation); |
| 147479 | if (childIndentationAmount !== -1 /* Constants.Unknown */) { |
| 147480 | inheritedIndentation = childIndentationAmount; |
| 147481 | } |
| 147482 | } |
| 147483 | // child node is outside the target range - do not dive inside |
| 147484 | if (!ts.rangeOverlapsWithStartEnd(originalRange, child.pos, child.end)) { |
| 147485 | if (child.end < originalRange.pos) { |
| 147486 | formattingScanner.skipToEndOf(child); |
| 147487 | } |
| 147488 | return inheritedIndentation; |
| 147489 | } |
| 147490 | if (child.getFullWidth() === 0) { |
no test coverage detected