(currentItem, currentStartLine, currentParent, previousItem, previousStartLine, previousParent, contextNode, dynamicIndentation)
| 147699 | return lineAction; |
| 147700 | } |
| 147701 | function processPair(currentItem, currentStartLine, currentParent, previousItem, previousStartLine, previousParent, contextNode, dynamicIndentation) { |
| 147702 | formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); |
| 147703 | var rules = getRules(formattingContext); |
| 147704 | var trimTrailingWhitespaces = formattingContext.options.trimTrailingWhitespace !== false; |
| 147705 | var lineAction = 0 /* LineAction.None */; |
| 147706 | if (rules) { |
| 147707 | // Apply rules in reverse order so that higher priority rules (which are first in the array) |
| 147708 | // win in a conflict with lower priority rules. |
| 147709 | ts.forEachRight(rules, function (rule) { |
| 147710 | lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); |
| 147711 | if (dynamicIndentation) { |
| 147712 | switch (lineAction) { |
| 147713 | case 2 /* LineAction.LineRemoved */: |
| 147714 | // Handle the case where the next line is moved to be the end of this line. |
| 147715 | // In this case we don't indent the next line in the next pass. |
| 147716 | if (currentParent.getStart(sourceFile) === currentItem.pos) { |
| 147717 | dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false, contextNode); |
| 147718 | } |
| 147719 | break; |
| 147720 | case 1 /* LineAction.LineAdded */: |
| 147721 | // Handle the case where token2 is moved to the new line. |
| 147722 | // In this case we indent token2 in the next pass but we set |
| 147723 | // sameLineIndent flag to notify the indenter that the indentation is within the line. |
| 147724 | if (currentParent.getStart(sourceFile) === currentItem.pos) { |
| 147725 | dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ true, contextNode); |
| 147726 | } |
| 147727 | break; |
| 147728 | default: |
| 147729 | ts.Debug.assert(lineAction === 0 /* LineAction.None */); |
| 147730 | } |
| 147731 | } |
| 147732 | // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line |
| 147733 | trimTrailingWhitespaces = trimTrailingWhitespaces && !(rule.action & 16 /* RuleAction.DeleteSpace */) && rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */; |
| 147734 | }); |
| 147735 | } |
| 147736 | else { |
| 147737 | trimTrailingWhitespaces = trimTrailingWhitespaces && currentItem.kind !== 1 /* SyntaxKind.EndOfFileToken */; |
| 147738 | } |
| 147739 | if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { |
| 147740 | // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line |
| 147741 | trimTrailingWhitespacesForLines(previousStartLine, currentStartLine, previousItem); |
| 147742 | } |
| 147743 | return lineAction; |
| 147744 | } |
| 147745 | function insertIndentation(pos, indentation, lineAdded) { |
| 147746 | var indentationString = getIndentationString(indentation, options); |
| 147747 | if (lineAdded) { |
no test coverage detected