(parent *ast.Node, node1 *ast.Node, node2 *ast.Node)
| 444 | } |
| 445 | |
| 446 | func (p *Printer) getLinesBetweenNodes(parent *ast.Node, node1 *ast.Node, node2 *ast.Node) int { |
| 447 | if p.shouldElideIndentation(parent) { |
| 448 | return 0 |
| 449 | } |
| 450 | |
| 451 | parent = skipSynthesizedParentheses(parent) |
| 452 | node1 = skipSynthesizedParentheses(node1) |
| 453 | node2 = skipSynthesizedParentheses(node2) |
| 454 | |
| 455 | // Always use a newline for synthesized code if the synthesizer desires it. |
| 456 | if p.shouldEmitOnNewLine(node2, LFNone) { |
| 457 | return 1 |
| 458 | } |
| 459 | |
| 460 | if p.currentSourceFile != nil && !ast.NodeIsSynthesized(parent) && !ast.NodeIsSynthesized(node1) && !ast.NodeIsSynthesized(node2) { |
| 461 | if p.Options.PreserveSourceNewlines { |
| 462 | return p.getEffectiveLines( |
| 463 | func(includeComments bool) int { |
| 464 | return getLinesBetweenRangeEndAndRangeStart( |
| 465 | node1.Loc, |
| 466 | node2.Loc, |
| 467 | p.currentSourceFile, |
| 468 | includeComments, |
| 469 | ) |
| 470 | }, |
| 471 | ) |
| 472 | } |
| 473 | return core.IfElse(rangeEndIsOnSameLineAsRangeStart(node1.Loc, node2.Loc, p.currentSourceFile), 0, 1) |
| 474 | } |
| 475 | |
| 476 | return 0 |
| 477 | } |
| 478 | |
| 479 | func (p *Printer) getEffectiveLines(getLineDifference func(includeComments bool) int) int { |
| 480 | // If 'preserveSourceNewlines' is disabled, we should never call this function |
no test coverage detected