Lines 936-942
Link Here
|
936 |
if (count == 0) { |
936 |
if (count == 0) { |
937 |
// preserve line breaks in wrapping if specified |
937 |
// preserve line breaks in wrapping if specified |
938 |
// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=198074 |
938 |
// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=198074 |
939 |
if (this.currentAlignment != null && this.formatter.preferences.preserve_existing_line_breaks) { |
939 |
if (this.currentAlignment != null && !this.formatter.preferences.join_wrapped_lines) { |
940 |
int savedIndentation = this.indentationLevel; |
940 |
int savedIndentation = this.indentationLevel; |
941 |
StringBuffer buffer = new StringBuffer(getNewLine()); |
941 |
StringBuffer buffer = new StringBuffer(getNewLine()); |
942 |
this.indentationLevel = this.currentAlignment.breakIndentationLevel; |
942 |
this.indentationLevel = this.currentAlignment.breakIndentationLevel; |
Lines 1427-1433
Link Here
|
1427 |
int hasTextOnFirstLine = 0; |
1427 |
int hasTextOnFirstLine = 0; |
1428 |
boolean firstWord = true; |
1428 |
boolean firstWord = true; |
1429 |
boolean clearBlankLines = this.formatter.preferences.comment_clear_blank_lines_in_block_comment; |
1429 |
boolean clearBlankLines = this.formatter.preferences.comment_clear_blank_lines_in_block_comment; |
1430 |
boolean preserveBreakLines = this.formatter.preferences.preserve_existing_line_breaks; |
1430 |
boolean joinLines = this.formatter.preferences.join_lines_in_comments; |
1431 |
int scannerLine = Util.getLineNumber(this.scanner.currentPosition, this.lineEnds, 0, this.maxLines); |
1431 |
int scannerLine = Util.getLineNumber(this.scanner.currentPosition, this.lineEnds, 0, this.maxLines); |
1432 |
int firstLine = scannerLine; |
1432 |
int firstLine = scannerLine; |
1433 |
int lineNumber = scannerLine; |
1433 |
int lineNumber = scannerLine; |
Lines 1534-1540
Link Here
|
1534 |
// insert one blank line before root tags |
1534 |
// insert one blank line before root tags |
1535 |
linesGap = 2; |
1535 |
linesGap = 2; |
1536 |
} |
1536 |
} |
1537 |
max = preserveBreakLines ? 0 : 1; |
1537 |
max = joinLines ? 1 : 0; |
1538 |
} |
1538 |
} |
1539 |
if (linesGap > max) { |
1539 |
if (linesGap > max) { |
1540 |
if (clearBlankLines) { |
1540 |
if (clearBlankLines) { |
Lines 1542-1548
Link Here
|
1542 |
if (token == TerminalTokens.TokenNameAT) { |
1542 |
if (token == TerminalTokens.TokenNameAT) { |
1543 |
linesGap = 1; |
1543 |
linesGap = 1; |
1544 |
} else { |
1544 |
} else { |
1545 |
linesGap = max==0 || preserveBreakLines ? 1 : 0; |
1545 |
linesGap = (max==0 || !joinLines) ? 1 : 0; |
1546 |
} |
1546 |
} |
1547 |
} |
1547 |
} |
1548 |
for (int i=0; i<linesGap; i++) { |
1548 |
for (int i=0; i<linesGap; i++) { |
Lines 1936-1942
Link Here
|
1936 |
} else if (hasLineComment) { |
1936 |
} else if (hasLineComment) { |
1937 |
preserveEmptyLines(count, this.scanner.getCurrentTokenStartPosition()); |
1937 |
preserveEmptyLines(count, this.scanner.getCurrentTokenStartPosition()); |
1938 |
addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition()); |
1938 |
addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition()); |
1939 |
} else if (count != 0 && (this.formatter.preferences.preserve_existing_line_breaks || this.formatter.preferences.number_of_empty_lines_to_preserve != 0)) { |
1939 |
} else if (count != 0 && (!this.formatter.preferences.join_wrapped_lines || this.formatter.preferences.number_of_empty_lines_to_preserve != 0)) { |
1940 |
addReplaceEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition(), getPreserveEmptyLines(count-1)); |
1940 |
addReplaceEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition(), getPreserveEmptyLines(count-1)); |
1941 |
} else { |
1941 |
} else { |
1942 |
addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition()); |
1942 |
addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition()); |
Lines 2444-2450
Link Here
|
2444 |
// tag section: iterate through the blocks composing this tag but the last one |
2444 |
// tag section: iterate through the blocks composing this tag but the last one |
2445 |
int previousLine = Util.getLineNumber(previousEnd, this.lineEnds, 0, this.maxLines); |
2445 |
int previousLine = Util.getLineNumber(previousEnd, this.lineEnds, 0, this.maxLines); |
2446 |
boolean clearBlankLines = this.formatter.preferences.comment_clear_blank_lines_in_javadoc_comment; |
2446 |
boolean clearBlankLines = this.formatter.preferences.comment_clear_blank_lines_in_javadoc_comment; |
2447 |
boolean preserveBreakLines = this.formatter.preferences.preserve_existing_line_breaks; |
2447 |
boolean joinLines = this.formatter.preferences.join_lines_in_comments; |
2448 |
for (int i=0; i<=maxNodes; i++) { |
2448 |
for (int i=0; i<=maxNodes; i++) { |
2449 |
FormatJavadocNode node = block.nodes[i]; |
2449 |
FormatJavadocNode node = block.nodes[i]; |
2450 |
int nodeStart = node.sourceStart; |
2450 |
int nodeStart = node.sourceStart; |
Lines 2454-2463
Link Here
|
2454 |
if (i == 0) { |
2454 |
if (i == 0) { |
2455 |
newLines = this.formatter.preferences.comment_insert_new_line_for_parameter && block.isParamTag() ? 1 : 0; |
2455 |
newLines = this.formatter.preferences.comment_insert_new_line_for_parameter && block.isParamTag() ? 1 : 0; |
2456 |
if (nodeStart > (previousEnd+1)) { |
2456 |
if (nodeStart > (previousEnd+1)) { |
2457 |
if (!clearBlankLines || preserveBreakLines) { |
2457 |
if (!clearBlankLines || !joinLines) { |
2458 |
int startLine = Util.getLineNumber(nodeStart, this.lineEnds, previousLine-1, this.maxLines); |
2458 |
int startLine = Util.getLineNumber(nodeStart, this.lineEnds, previousLine-1, this.maxLines); |
2459 |
int gapLine = previousLine; |
2459 |
int gapLine = previousLine; |
2460 |
if (!preserveBreakLines) gapLine++; // if not preserving line break then gap must be at least of one line |
2460 |
if (joinLines) gapLine++; // if not preserving line break then gap must be at least of one line |
2461 |
if (startLine > gapLine) { |
2461 |
if (startLine > gapLine) { |
2462 |
newLines = startLine - previousLine; |
2462 |
newLines = startLine - previousLine; |
2463 |
} |
2463 |
} |
Lines 3324-3330
Link Here
|
3324 |
private void printJavadocText(FormatJavadocText text, FormatJavadocBlock block, boolean textOnNewLine) { |
3324 |
private void printJavadocText(FormatJavadocText text, FormatJavadocBlock block, boolean textOnNewLine) { |
3325 |
|
3325 |
|
3326 |
boolean clearBlankLines = this.formatter.preferences.comment_clear_blank_lines_in_javadoc_comment; |
3326 |
boolean clearBlankLines = this.formatter.preferences.comment_clear_blank_lines_in_javadoc_comment; |
3327 |
boolean preserveBreakLines = this.formatter.preferences.preserve_existing_line_breaks; |
3327 |
boolean joinLines = this.formatter.preferences.join_lines_in_comments; |
3328 |
StringBuffer buffer = new StringBuffer(); |
3328 |
StringBuffer buffer = new StringBuffer(); |
3329 |
int textStart = text.sourceStart; |
3329 |
int textStart = text.sourceStart; |
3330 |
int nextStart = textStart; |
3330 |
int nextStart = textStart; |
Lines 3347-3357
Link Here
|
3347 |
|
3347 |
|
3348 |
// Replace with current buffer if there are several empty lines between text lines |
3348 |
// Replace with current buffer if there are several empty lines between text lines |
3349 |
nextStart = (int) text.separators[idx]; |
3349 |
nextStart = (int) text.separators[idx]; |
3350 |
if (!clearBlankLines || preserveBreakLines) { |
3350 |
if (!clearBlankLines || !joinLines) { |
3351 |
int endLine = Util.getLineNumber(end, this.lineEnds, startLine-1, this.maxLines); |
3351 |
int endLine = Util.getLineNumber(end, this.lineEnds, startLine-1, this.maxLines); |
3352 |
startLine = Util.getLineNumber(nextStart, this.lineEnds, endLine-1, this.maxLines); |
3352 |
startLine = Util.getLineNumber(nextStart, this.lineEnds, endLine-1, this.maxLines); |
3353 |
int gapLine = endLine; |
3353 |
int gapLine = endLine; |
3354 |
if (!preserveBreakLines) gapLine++; // if not preserving line break then gap must be at least of one line |
3354 |
if (joinLines) gapLine++; // if not preserving line break then gap must be at least of one line |
3355 |
if (startLine > gapLine) { |
3355 |
if (startLine > gapLine) { |
3356 |
addReplaceEdit(textStart, end, buffer.toString()); |
3356 |
addReplaceEdit(textStart, end, buffer.toString()); |
3357 |
textStart = nextStart; |
3357 |
textStart = nextStart; |