(node *ast.Node, contextNode *ast.Node, nodeStartLine int, undecoratedNodeStartLine int, indentation int, delta int)
| 603 | } |
| 604 | |
| 605 | func (w *formatSpanWorker) processNode(node *ast.Node, contextNode *ast.Node, nodeStartLine int, undecoratedNodeStartLine int, indentation int, delta int) { |
| 606 | if !w.originalRange.Overlaps(withTokenStart(node, w.sourceFile)) { |
| 607 | return |
| 608 | } |
| 609 | |
| 610 | nodeDynamicIndentation := w.getDynamicIndentation(node, nodeStartLine, indentation, delta) |
| 611 | |
| 612 | // a useful observations when tracking context node |
| 613 | // / |
| 614 | // [a] |
| 615 | // / | \ |
| 616 | // [b] [c] [d] |
| 617 | // node 'a' is a context node for nodes 'b', 'c', 'd' |
| 618 | // except for the leftmost leaf token in [b] - in this case context node ('e') is located somewhere above 'a' |
| 619 | // this rule can be applied recursively to child nodes of 'a'. |
| 620 | // |
| 621 | // context node is set to parent node value after processing every child node |
| 622 | // context node is set to parent of the token after processing every token |
| 623 | |
| 624 | w.childContextNode = contextNode |
| 625 | |
| 626 | // if there are any tokens that logically belong to node and interleave child nodes |
| 627 | // such tokens will be consumed in processChildNode for the child that follows them |
| 628 | w.executeProcessNodeVisitor(node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine) |
| 629 | |
| 630 | // proceed any tokens in the node that are located after child nodes |
| 631 | for w.formattingScanner.isOnToken() && w.formattingScanner.getTokenFullStart() < w.originalRange.End() { |
| 632 | tokenInfo := w.formattingScanner.readTokenInfo(node) |
| 633 | if tokenInfo.token.Loc.End() > min(node.End(), w.originalRange.End()) { |
| 634 | break |
| 635 | } |
| 636 | w.consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node, false) |
| 637 | } |
| 638 | } |
| 639 | |
| 640 | func (w *formatSpanWorker) processPair(currentItem TextRangeWithKind, currentStartLine int, currentParent *ast.Node, previousItem TextRangeWithKind, previousStartLine int, previousParent *ast.Node, contextNode *ast.Node, dynamicIndentation *dynamicIndenter) LineAction { |
| 641 | w.formattingContext.UpdateContext(previousItem, previousParent, currentItem, currentParent, contextNode) |
no test coverage detected