Lines 16-21
Link Here
|
16 |
import org.eclipse.jdt.core.JavaCore; |
16 |
import org.eclipse.jdt.core.JavaCore; |
17 |
import org.eclipse.jdt.core.compiler.IProblem; |
17 |
import org.eclipse.jdt.core.compiler.IProblem; |
18 |
import org.eclipse.jdt.core.compiler.InvalidInputException; |
18 |
import org.eclipse.jdt.core.compiler.InvalidInputException; |
|
|
19 |
import org.eclipse.jdt.core.formatter.CodeFormatter; |
19 |
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; |
20 |
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; |
20 |
import org.eclipse.jdt.internal.compiler.ASTVisitor; |
21 |
import org.eclipse.jdt.internal.compiler.ASTVisitor; |
21 |
import org.eclipse.jdt.internal.compiler.ast.AND_AND_Expression; |
22 |
import org.eclipse.jdt.internal.compiler.ast.AND_AND_Expression; |
Lines 169-175
Link Here
|
169 |
TerminalTokens.TokenNameUNSIGNED_RIGHT_SHIFT, |
170 |
TerminalTokens.TokenNameUNSIGNED_RIGHT_SHIFT, |
170 |
TerminalTokens.TokenNameGREATER |
171 |
TerminalTokens.TokenNameGREATER |
171 |
}; |
172 |
}; |
172 |
private int chunkKind; |
|
|
173 |
public int lastLocalDeclarationSourceStart; |
173 |
public int lastLocalDeclarationSourceStart; |
174 |
private Scanner localScanner; |
174 |
private Scanner localScanner; |
175 |
public DefaultCodeFormatterOptions preferences; |
175 |
public DefaultCodeFormatterOptions preferences; |
Lines 261-273
Link Here
|
261 |
messageSend.traverse(builder, scope); |
261 |
messageSend.traverse(builder, scope); |
262 |
return builder; |
262 |
return builder; |
263 |
} |
263 |
} |
264 |
public boolean checkChunkStart(int kind) { |
|
|
265 |
if (this.chunkKind != kind) { |
266 |
this.chunkKind = kind; |
267 |
return true; |
268 |
} |
269 |
return false; |
270 |
} |
271 |
|
264 |
|
272 |
private boolean commentStartsBlock(int start, int end) { |
265 |
private boolean commentStartsBlock(int start, int end) { |
273 |
this.localScanner.resetTo(start, end); |
266 |
this.localScanner.resetTo(start, end); |
Lines 439-447
Link Here
|
439 |
for (int i = 0; i < fragmentsSize - 1; i++) { |
432 |
for (int i = 0; i < fragmentsSize - 1; i++) { |
440 |
ASTNode fragment = fragments[i]; |
433 |
ASTNode fragment = fragments[i]; |
441 |
fragment.traverse(this, scope); |
434 |
fragment.traverse(this, scope); |
442 |
this.scribe.printTrailingComment(); |
435 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
443 |
if (this.scribe.lastNumberOfNewLines == 1) { |
436 |
if (this.scribe.lastNumberOfNewLines == 1) { |
444 |
// a new line has been inserted by printTrailingComment() |
437 |
// a new line has been inserted by printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT) |
445 |
this.scribe.indentationLevel = binaryExpressionAlignment.breakIndentationLevel; |
438 |
this.scribe.indentationLevel = binaryExpressionAlignment.breakIndentationLevel; |
446 |
} |
439 |
} |
447 |
if (this.preferences.wrap_before_binary_operator) { |
440 |
if (this.preferences.wrap_before_binary_operator) { |
Lines 460-466
Link Here
|
460 |
} |
453 |
} |
461 |
} |
454 |
} |
462 |
fragments[fragmentsSize - 1].traverse(this, scope); |
455 |
fragments[fragmentsSize - 1].traverse(this, scope); |
463 |
this.scribe.printTrailingComment(); |
456 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
464 |
ok = true; |
457 |
ok = true; |
465 |
} catch(AlignmentException e){ |
458 |
} catch(AlignmentException e){ |
466 |
this.scribe.redoAlignment(e); |
459 |
this.scribe.redoAlignment(e); |
Lines 616-631
Link Here
|
616 |
|
609 |
|
617 |
if (memberAlignment != null) { |
610 |
if (memberAlignment != null) { |
618 |
this.scribe.alignFragment(memberAlignment, 2); |
611 |
this.scribe.alignFragment(memberAlignment, 2); |
619 |
this.scribe.printTrailingComment(); |
612 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
620 |
} else { |
613 |
} else { |
621 |
this.scribe.space(); |
614 |
this.scribe.space(); |
622 |
this.scribe.printTrailingComment(); |
615 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
623 |
} |
616 |
} |
624 |
} |
617 |
} |
625 |
|
618 |
|
626 |
private void format(ImportReference importRef, boolean isLast) { |
619 |
private void format(ImportReference importRef, boolean isLast) { |
627 |
this.scribe.printNextToken(TerminalTokens.TokenNameimport); |
620 |
this.scribe.printNextToken(TerminalTokens.TokenNameimport); |
628 |
this.preferences.number_of_empty_lines_to_preserve = this.preferences.blank_lines_between_import_groups; |
621 |
if (!isLast) this.scribe.blank_lines_between_import_groups = this.preferences.blank_lines_between_import_groups; |
629 |
this.scribe.space(); |
622 |
this.scribe.space(); |
630 |
if (importRef.isStatic()) { |
623 |
if (importRef.isStatic()) { |
631 |
this.scribe.printNextToken(TerminalTokens.TokenNamestatic); |
624 |
this.scribe.printNextToken(TerminalTokens.TokenNamestatic); |
Lines 641-649
Link Here
|
641 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
634 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
642 |
} |
635 |
} |
643 |
if (isLast) { |
636 |
if (isLast) { |
644 |
this.scribe.printTrailingComment(); |
637 |
this.scribe.blank_lines_between_import_groups = -1; |
|
|
638 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.IMPORT_TRAILING_COMMENT); |
645 |
} else { |
639 |
} else { |
646 |
this.scribe.printTrailingComment(this.preferences.blank_lines_between_import_groups); |
640 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.NO_TRAILING_COMMENT); |
|
|
641 |
this.scribe.blank_lines_between_import_groups = -1; |
647 |
} |
642 |
} |
648 |
this.scribe.printNewLine(); |
643 |
this.scribe.printNewLine(); |
649 |
} |
644 |
} |
Lines 726-732
Link Here
|
726 |
|
721 |
|
727 |
if (i != length - 1) { |
722 |
if (i != length - 1) { |
728 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_multiple_field_declarations); |
723 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_multiple_field_declarations); |
729 |
this.scribe.printTrailingComment(); |
724 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
730 |
this.scribe.alignFragment(multiFieldDeclarationsAlignment, i); |
725 |
this.scribe.alignFragment(multiFieldDeclarationsAlignment, i); |
731 |
|
726 |
|
732 |
if (this.preferences.insert_space_after_comma_in_multiple_field_declarations) { |
727 |
if (this.preferences.insert_space_after_comma_in_multiple_field_declarations) { |
Lines 735-741
Link Here
|
735 |
} else { |
730 |
} else { |
736 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
731 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
737 |
this.scribe.alignFragment(fieldAlignment, 2); |
732 |
this.scribe.alignFragment(fieldAlignment, 2); |
738 |
this.scribe.printTrailingComment(); |
733 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
739 |
} |
734 |
} |
740 |
} |
735 |
} |
741 |
ok = true; |
736 |
ok = true; |
Lines 1048-1054
Link Here
|
1048 |
for (int i = 0; i < superInterfaceLength; i++) { |
1043 |
for (int i = 0; i < superInterfaceLength; i++) { |
1049 |
if (i > 0) { |
1044 |
if (i > 0) { |
1050 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_superinterfaces); |
1045 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_superinterfaces); |
1051 |
this.scribe.printTrailingComment(); |
1046 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
1052 |
this.scribe.alignFragment(interfaceAlignment, i+1); |
1047 |
this.scribe.alignFragment(interfaceAlignment, i+1); |
1053 |
if (this.preferences.insert_space_after_comma_in_superinterfaces) { |
1048 |
if (this.preferences.insert_space_after_comma_in_superinterfaces) { |
1054 |
this.scribe.space(); |
1049 |
this.scribe.space(); |
Lines 1143-1149
Link Here
|
1143 |
if (this.preferences.insert_space_after_comma_in_enum_declarations) { |
1138 |
if (this.preferences.insert_space_after_comma_in_enum_declarations) { |
1144 |
this.scribe.space(); |
1139 |
this.scribe.space(); |
1145 |
} |
1140 |
} |
1146 |
this.scribe.printTrailingComment(); |
1141 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
1147 |
if (fieldDeclaration.initialization instanceof QualifiedAllocationExpression) { |
1142 |
if (fieldDeclaration.initialization instanceof QualifiedAllocationExpression) { |
1148 |
this.scribe.printNewLine(); |
1143 |
this.scribe.printNewLine(); |
1149 |
} |
1144 |
} |
Lines 1164-1170
Link Here
|
1164 |
if (this.preferences.insert_space_after_comma_in_enum_declarations) { |
1159 |
if (this.preferences.insert_space_after_comma_in_enum_declarations) { |
1165 |
this.scribe.space(); |
1160 |
this.scribe.space(); |
1166 |
} |
1161 |
} |
1167 |
this.scribe.printTrailingComment(); |
1162 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
1168 |
if (fieldDeclaration.initialization instanceof QualifiedAllocationExpression) { |
1163 |
if (fieldDeclaration.initialization instanceof QualifiedAllocationExpression) { |
1169 |
this.scribe.printNewLine(); |
1164 |
this.scribe.printNewLine(); |
1170 |
} |
1165 |
} |
Lines 1173-1179
Link Here
|
1173 |
} |
1168 |
} |
1174 |
if (isNextToken(TerminalTokens.TokenNameSEMICOLON)) { |
1169 |
if (isNextToken(TerminalTokens.TokenNameSEMICOLON)) { |
1175 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
1170 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
1176 |
this.scribe.printTrailingComment(); |
1171 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
1177 |
if (hasConstants |
1172 |
if (hasConstants |
1178 |
|| ((enumConstantsLength - length) != 0) |
1173 |
|| ((enumConstantsLength - length) != 0) |
1179 |
|| typeDeclaration.methods != null |
1174 |
|| typeDeclaration.methods != null |
Lines 1210-1216
Link Here
|
1210 |
} |
1205 |
} |
1211 |
} |
1206 |
} |
1212 |
this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE); |
1207 |
this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE); |
1213 |
this.scribe.printTrailingComment(); |
1208 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
1214 |
if (class_declaration_brace.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) { |
1209 |
if (class_declaration_brace.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) { |
1215 |
this.scribe.unIndent(); |
1210 |
this.scribe.unIndent(); |
1216 |
} |
1211 |
} |
Lines 1305-1311
Link Here
|
1305 |
} |
1300 |
} |
1306 |
} |
1301 |
} |
1307 |
this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE); |
1302 |
this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE); |
1308 |
this.scribe.printTrailingComment(); |
1303 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
1309 |
if (DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(block_brace_position)) { |
1304 |
if (DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(block_brace_position)) { |
1310 |
this.scribe.unIndent(); |
1305 |
this.scribe.unIndent(); |
1311 |
} |
1306 |
} |
Lines 1367-1373
Link Here
|
1367 |
for (int j = 0; j < argumentLength; j++) { |
1362 |
for (int j = 0; j < argumentLength; j++) { |
1368 |
if (j > 0) { |
1363 |
if (j > 0) { |
1369 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_method_invocation_arguments); |
1364 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_method_invocation_arguments); |
1370 |
this.scribe.printTrailingComment(); |
1365 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
1371 |
} |
1366 |
} |
1372 |
this.scribe.alignFragment(argumentsAlignment, j); |
1367 |
this.scribe.alignFragment(argumentsAlignment, j); |
1373 |
if (j > 0 && this.preferences.insert_space_after_comma_in_method_invocation_arguments) { |
1368 |
if (j > 0 && this.preferences.insert_space_after_comma_in_method_invocation_arguments) { |
Lines 1452-1458
Link Here
|
1452 |
for (int j = 0; j < argumentLength; j++) { |
1447 |
for (int j = 0; j < argumentLength; j++) { |
1453 |
if (j > 0) { |
1448 |
if (j > 0) { |
1454 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_method_invocation_arguments); |
1449 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_method_invocation_arguments); |
1455 |
this.scribe.printTrailingComment(); |
1450 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
1456 |
} |
1451 |
} |
1457 |
this.scribe.alignFragment(argumentsAlignment, j); |
1452 |
this.scribe.alignFragment(argumentsAlignment, j); |
1458 |
if (j > 0 && this.preferences.insert_space_after_comma_in_method_invocation_arguments) { |
1453 |
if (j > 0 && this.preferences.insert_space_after_comma_in_method_invocation_arguments) { |
Lines 1532-1538
Link Here
|
1532 |
} |
1527 |
} |
1533 |
if (isNextToken(TerminalTokens.TokenNameSEMICOLON)) { |
1528 |
if (isNextToken(TerminalTokens.TokenNameSEMICOLON)) { |
1534 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
1529 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
1535 |
this.scribe.printTrailingComment(); |
1530 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
1536 |
} |
1531 |
} |
1537 |
if (i != max - 1) { |
1532 |
if (i != max - 1) { |
1538 |
this.scribe.printNewLine(); |
1533 |
this.scribe.printNewLine(); |
Lines 1556-1562
Link Here
|
1556 |
while(isNextToken(TerminalTokens.TokenNameSEMICOLON)) { |
1551 |
while(isNextToken(TerminalTokens.TokenNameSEMICOLON)) { |
1557 |
this.scribe.printComment(); |
1552 |
this.scribe.printComment(); |
1558 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
1553 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
1559 |
this.scribe.printTrailingComment(); |
1554 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
1560 |
} |
1555 |
} |
1561 |
if (hasSemiColon && isFirst) { |
1556 |
if (hasSemiColon && isFirst) { |
1562 |
this.scribe.printNewLine(); |
1557 |
this.scribe.printNewLine(); |
Lines 1571-1577
Link Here
|
1571 |
final Statement[] statements = block.statements; |
1566 |
final Statement[] statements = block.statements; |
1572 |
statements[0].traverse(this, scope); |
1567 |
statements[0].traverse(this, scope); |
1573 |
this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE, true); |
1568 |
this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE, true); |
1574 |
this.scribe.printTrailingComment(); |
1569 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
1575 |
} |
1570 |
} |
1576 |
|
1571 |
|
1577 |
private void formatLeftCurlyBrace(final int line, final String bracePosition) { |
1572 |
private void formatLeftCurlyBrace(final int line, final String bracePosition) { |
Lines 1657-1663
Link Here
|
1657 |
if (insertSpaceAfterComma) { |
1652 |
if (insertSpaceAfterComma) { |
1658 |
this.scribe.space(); |
1653 |
this.scribe.space(); |
1659 |
} |
1654 |
} |
1660 |
this.scribe.printTrailingComment(); |
1655 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
1661 |
} |
1656 |
} |
1662 |
} |
1657 |
} |
1663 |
|
1658 |
|
Lines 1714-1720
Link Here
|
1714 |
for (int i = 0; i < argumentsLength; i++) { |
1709 |
for (int i = 0; i < argumentsLength; i++) { |
1715 |
if (i > 0) { |
1710 |
if (i > 0) { |
1716 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_method_invocation_arguments); |
1711 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_method_invocation_arguments); |
1717 |
this.scribe.printTrailingComment(); |
1712 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
1718 |
} |
1713 |
} |
1719 |
this.scribe.alignFragment(argumentsAlignment, i); |
1714 |
this.scribe.alignFragment(argumentsAlignment, i); |
1720 |
if (i > 0 && this.preferences.insert_space_after_comma_in_method_invocation_arguments) { |
1715 |
if (i > 0 && this.preferences.insert_space_after_comma_in_method_invocation_arguments) { |
Lines 1732-1738
Link Here
|
1732 |
for (int i = 0; i < argumentsLength; i++) { |
1727 |
for (int i = 0; i < argumentsLength; i++) { |
1733 |
if (i > 0) { |
1728 |
if (i > 0) { |
1734 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_method_invocation_arguments); |
1729 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_method_invocation_arguments); |
1735 |
this.scribe.printTrailingComment(); |
1730 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
1736 |
} |
1731 |
} |
1737 |
if (i > 0 && this.preferences.insert_space_after_comma_in_method_invocation_arguments) { |
1732 |
if (i > 0 && this.preferences.insert_space_after_comma_in_method_invocation_arguments) { |
1738 |
this.scribe.space(); |
1733 |
this.scribe.space(); |
Lines 1776-1782
Link Here
|
1776 |
for (int i = 0; i < argumentLength; i++) { |
1771 |
for (int i = 0; i < argumentLength; i++) { |
1777 |
if (i > 0) { |
1772 |
if (i > 0) { |
1778 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, spaceBeforeComma); |
1773 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, spaceBeforeComma); |
1779 |
this.scribe.printTrailingComment(); |
1774 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
1780 |
} |
1775 |
} |
1781 |
this.scribe.alignFragment(argumentsAlignment, i); |
1776 |
this.scribe.alignFragment(argumentsAlignment, i); |
1782 |
if (i > 0 && spaceAfterComma) { |
1777 |
if (i > 0 && spaceAfterComma) { |
Lines 1830-1836
Link Here
|
1830 |
for (int i = 0; i < argumentLength; i++) { |
1825 |
for (int i = 0; i < argumentLength; i++) { |
1831 |
if (i > 0) { |
1826 |
if (i > 0) { |
1832 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, spaceBeforeComma); |
1827 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, spaceBeforeComma); |
1833 |
this.scribe.printTrailingComment(); |
1828 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
1834 |
} |
1829 |
} |
1835 |
this.scribe.alignFragment(argumentsAlignment, i); |
1830 |
this.scribe.alignFragment(argumentsAlignment, i); |
1836 |
if (i > 0 && spaceAfterComma) { |
1831 |
if (i > 0 && spaceAfterComma) { |
Lines 1856-1866
Link Here
|
1856 |
this.scribe.printNewLine(); |
1851 |
this.scribe.printNewLine(); |
1857 |
this.scribe.indent(); |
1852 |
this.scribe.indent(); |
1858 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
1853 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
1859 |
this.scribe.printTrailingComment(); |
1854 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
1860 |
this.scribe.unIndent(); |
1855 |
this.scribe.unIndent(); |
1861 |
} else { |
1856 |
} else { |
1862 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
1857 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
1863 |
this.scribe.printTrailingComment(); |
1858 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
1864 |
} |
1859 |
} |
1865 |
} |
1860 |
} |
1866 |
|
1861 |
|
Lines 1873-1879
Link Here
|
1873 |
this.scribe.indent(); |
1868 |
this.scribe.indent(); |
1874 |
} |
1869 |
} |
1875 |
this.scribe.printNextToken(TerminalTokens.TokenNameLBRACE, insertSpaceBeforeBrace); |
1870 |
this.scribe.printNextToken(TerminalTokens.TokenNameLBRACE, insertSpaceBeforeBrace); |
1876 |
this.scribe.printTrailingComment(); |
1871 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
1877 |
} |
1872 |
} |
1878 |
private void formatStatements(BlockScope scope, final Statement[] statements, boolean insertNewLineAfterLastStatement) { |
1873 |
private void formatStatements(BlockScope scope, final Statement[] statements, boolean insertNewLineAfterLastStatement) { |
1879 |
int statementsLength = statements.length; |
1874 |
int statementsLength = statements.length; |
Lines 1885-1891
Link Here
|
1885 |
statement.traverse(this, scope); |
1880 |
statement.traverse(this, scope); |
1886 |
if (statement instanceof Expression) { |
1881 |
if (statement instanceof Expression) { |
1887 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
1882 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
1888 |
this.scribe.printTrailingComment(); |
1883 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
1889 |
if (i != statementsLength - 1) { |
1884 |
if (i != statementsLength - 1) { |
1890 |
if (!(statement instanceof EmptyStatement) && !(statements[i + 1] instanceof EmptyStatement)) { |
1885 |
if (!(statement instanceof EmptyStatement) && !(statements[i + 1] instanceof EmptyStatement)) { |
1891 |
this.scribe.printNewLine(); |
1886 |
this.scribe.printNewLine(); |
Lines 1903-1909
Link Here
|
1903 |
LocalDeclaration nextLocal = (LocalDeclaration) statements[i + 1]; |
1898 |
LocalDeclaration nextLocal = (LocalDeclaration) statements[i + 1]; |
1904 |
if (currentLocal.declarationSourceStart != nextLocal.declarationSourceStart) { |
1899 |
if (currentLocal.declarationSourceStart != nextLocal.declarationSourceStart) { |
1905 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
1900 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
1906 |
this.scribe.printTrailingComment(); |
1901 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
1907 |
if (i != statementsLength - 1) { |
1902 |
if (i != statementsLength - 1) { |
1908 |
if (!(statement instanceof EmptyStatement) && !(statements[i + 1] instanceof EmptyStatement)) { |
1903 |
if (!(statement instanceof EmptyStatement) && !(statements[i + 1] instanceof EmptyStatement)) { |
1909 |
this.scribe.printNewLine(); |
1904 |
this.scribe.printNewLine(); |
Lines 1914-1920
Link Here
|
1914 |
} |
1909 |
} |
1915 |
} else { |
1910 |
} else { |
1916 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
1911 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
1917 |
this.scribe.printTrailingComment(); |
1912 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
1918 |
if (i != statementsLength - 1) { |
1913 |
if (i != statementsLength - 1) { |
1919 |
if (!(statement instanceof EmptyStatement) && !(statements[i + 1] instanceof EmptyStatement)) { |
1914 |
if (!(statement instanceof EmptyStatement) && !(statements[i + 1] instanceof EmptyStatement)) { |
1920 |
this.scribe.printNewLine(); |
1915 |
this.scribe.printNewLine(); |
Lines 1925-1931
Link Here
|
1925 |
} |
1920 |
} |
1926 |
} else { |
1921 |
} else { |
1927 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
1922 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
1928 |
this.scribe.printTrailingComment(); |
1923 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
1929 |
if (i != statementsLength - 1) { |
1924 |
if (i != statementsLength - 1) { |
1930 |
if (!(statement instanceof EmptyStatement) && !(statements[i + 1] instanceof EmptyStatement)) { |
1925 |
if (!(statement instanceof EmptyStatement) && !(statements[i + 1] instanceof EmptyStatement)) { |
1931 |
this.scribe.printNewLine(); |
1926 |
this.scribe.printNewLine(); |
Lines 1969-1975
Link Here
|
1969 |
for (int i = 0; i < thrownExceptionsLength; i++) { |
1964 |
for (int i = 0; i < thrownExceptionsLength; i++) { |
1970 |
if (i > 0) { |
1965 |
if (i > 0) { |
1971 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, spaceBeforeComma); |
1966 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, spaceBeforeComma); |
1972 |
this.scribe.printTrailingComment(); |
1967 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
1973 |
this.scribe.alignFragment(throwsAlignment, i); |
1968 |
this.scribe.alignFragment(throwsAlignment, i); |
1974 |
if (spaceAfterComma) { |
1969 |
if (spaceAfterComma) { |
1975 |
this.scribe.space(); |
1970 |
this.scribe.space(); |
Lines 2047-2053
Link Here
|
2047 |
} |
2042 |
} |
2048 |
if (isNextToken(TerminalTokens.TokenNameSEMICOLON)) { |
2043 |
if (isNextToken(TerminalTokens.TokenNameSEMICOLON)) { |
2049 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
2044 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
2050 |
this.scribe.printTrailingComment(); |
2045 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
2051 |
} |
2046 |
} |
2052 |
this.scribe.printNewLine(); |
2047 |
this.scribe.printNewLine(); |
2053 |
// realign to the proper value |
2048 |
// realign to the proper value |
Lines 2065-2071
Link Here
|
2065 |
} else if (isNextToken(TerminalTokens.TokenNameSEMICOLON)) { |
2060 |
} else if (isNextToken(TerminalTokens.TokenNameSEMICOLON)) { |
2066 |
// the only body declaration is an empty declaration (';') |
2061 |
// the only body declaration is an empty declaration (';') |
2067 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
2062 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
2068 |
this.scribe.printTrailingComment(); |
2063 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
2069 |
} |
2064 |
} |
2070 |
this.scribe.printComment(); |
2065 |
this.scribe.printComment(); |
2071 |
this.scribe.exitMemberAlignment(memberAlignment); |
2066 |
this.scribe.exitMemberAlignment(memberAlignment); |
Lines 2296-2302
Link Here
|
2296 |
case TerminalTokens.TokenNameCOMMENT_JAVADOC : |
2291 |
case TerminalTokens.TokenNameCOMMENT_JAVADOC : |
2297 |
case TerminalTokens.TokenNameCOMMENT_BLOCK : |
2292 |
case TerminalTokens.TokenNameCOMMENT_BLOCK : |
2298 |
case TerminalTokens.TokenNameCOMMENT_LINE : |
2293 |
case TerminalTokens.TokenNameCOMMENT_LINE : |
2299 |
this.scribe.printComment(token); |
2294 |
this.scribe.printComment(token, Scribe.NO_TRAILING_COMMENT); |
2300 |
break; |
2295 |
break; |
2301 |
} |
2296 |
} |
2302 |
} catch(InvalidInputException e) { |
2297 |
} catch(InvalidInputException e) { |
Lines 2364-2370
Link Here
|
2364 |
for (int i = 0; i < argumentLength; i++) { |
2359 |
for (int i = 0; i < argumentLength; i++) { |
2365 |
if (i > 0) { |
2360 |
if (i > 0) { |
2366 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_allocation_expression); |
2361 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_allocation_expression); |
2367 |
this.scribe.printTrailingComment(); |
2362 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
2368 |
} |
2363 |
} |
2369 |
this.scribe.alignFragment(argumentsAlignment, i); |
2364 |
this.scribe.alignFragment(argumentsAlignment, i); |
2370 |
if (i > 0 && this.preferences.insert_space_after_comma_in_allocation_expression) { |
2365 |
if (i > 0 && this.preferences.insert_space_after_comma_in_allocation_expression) { |
Lines 2441-2447
Link Here
|
2441 |
defaultValue.traverse(this, (BlockScope) null); |
2436 |
defaultValue.traverse(this, (BlockScope) null); |
2442 |
} |
2437 |
} |
2443 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
2438 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
2444 |
this.scribe.printTrailingComment(); |
2439 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
2445 |
return false; |
2440 |
return false; |
2446 |
} |
2441 |
} |
2447 |
|
2442 |
|
Lines 2577-2583
Link Here
|
2577 |
expressions[0].traverse(this, scope); |
2572 |
expressions[0].traverse(this, scope); |
2578 |
for (int i = 1; i < expressionsLength; i++) { |
2573 |
for (int i = 1; i < expressionsLength; i++) { |
2579 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_array_initializer); |
2574 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_array_initializer); |
2580 |
this.scribe.printTrailingComment(); |
2575 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
2581 |
this.scribe.alignFragment(arrayInitializerAlignment, i); |
2576 |
this.scribe.alignFragment(arrayInitializerAlignment, i); |
2582 |
if (this.preferences.insert_space_after_comma_in_array_initializer) { |
2577 |
if (this.preferences.insert_space_after_comma_in_array_initializer) { |
2583 |
this.scribe.space(); |
2578 |
this.scribe.space(); |
Lines 2586-2592
Link Here
|
2586 |
if (i == expressionsLength - 1) { |
2581 |
if (i == expressionsLength - 1) { |
2587 |
if (isNextToken(TerminalTokens.TokenNameCOMMA)) { |
2582 |
if (isNextToken(TerminalTokens.TokenNameCOMMA)) { |
2588 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_array_initializer); |
2583 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_array_initializer); |
2589 |
this.scribe.printTrailingComment(); |
2584 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
2590 |
} |
2585 |
} |
2591 |
} |
2586 |
} |
2592 |
} |
2587 |
} |
Lines 2610-2616
Link Here
|
2610 |
expressions[0].traverse(this, scope); |
2605 |
expressions[0].traverse(this, scope); |
2611 |
if (isNextToken(TerminalTokens.TokenNameCOMMA)) { |
2606 |
if (isNextToken(TerminalTokens.TokenNameCOMMA)) { |
2612 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_array_initializer); |
2607 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_array_initializer); |
2613 |
this.scribe.printTrailingComment(); |
2608 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
2614 |
} |
2609 |
} |
2615 |
if (insert_new_line_after_opening_brace) { |
2610 |
if (insert_new_line_after_opening_brace) { |
2616 |
this.scribe.unIndent(); |
2611 |
this.scribe.unIndent(); |
Lines 2632-2645
Link Here
|
2632 |
this.scribe.printNextToken(TerminalTokens.TokenNameLBRACE, this.preferences.insert_space_before_opening_brace_in_array_initializer); |
2627 |
this.scribe.printNextToken(TerminalTokens.TokenNameLBRACE, this.preferences.insert_space_before_opening_brace_in_array_initializer); |
2633 |
if (isNextToken(TerminalTokens.TokenNameCOMMA)) { |
2628 |
if (isNextToken(TerminalTokens.TokenNameCOMMA)) { |
2634 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_array_initializer); |
2629 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_array_initializer); |
2635 |
this.scribe.printTrailingComment(); |
2630 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
2636 |
} |
2631 |
} |
2637 |
this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE, this.preferences.insert_space_between_empty_braces_in_array_initializer); |
2632 |
this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE, this.preferences.insert_space_between_empty_braces_in_array_initializer); |
2638 |
} else { |
2633 |
} else { |
2639 |
formatOpeningBrace(array_initializer_brace_position, this.preferences.insert_space_before_opening_brace_in_array_initializer); |
2634 |
formatOpeningBrace(array_initializer_brace_position, this.preferences.insert_space_before_opening_brace_in_array_initializer); |
2640 |
if (isNextToken(TerminalTokens.TokenNameCOMMA)) { |
2635 |
if (isNextToken(TerminalTokens.TokenNameCOMMA)) { |
2641 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_array_initializer); |
2636 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_array_initializer); |
2642 |
this.scribe.printTrailingComment(); |
2637 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
2643 |
} |
2638 |
} |
2644 |
this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE, this.preferences.insert_space_between_empty_braces_in_array_initializer); |
2639 |
this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE, this.preferences.insert_space_between_empty_braces_in_array_initializer); |
2645 |
if (array_initializer_brace_position.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) { |
2640 |
if (array_initializer_brace_position.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) { |
Lines 2808-2814
Link Here
|
2808 |
assertStatement.exceptionArgument.traverse(this, scope); |
2803 |
assertStatement.exceptionArgument.traverse(this, scope); |
2809 |
} |
2804 |
} |
2810 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
2805 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
2811 |
this.scribe.printTrailingComment(); |
2806 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
2812 |
return false; |
2807 |
return false; |
2813 |
} |
2808 |
} |
2814 |
|
2809 |
|
Lines 2906-2912
Link Here
|
2906 |
this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, true); |
2901 |
this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, true); |
2907 |
} |
2902 |
} |
2908 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
2903 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
2909 |
this.scribe.printTrailingComment(); |
2904 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
2910 |
return false; |
2905 |
return false; |
2911 |
} |
2906 |
} |
2912 |
|
2907 |
|
Lines 3034-3040
Link Here
|
3034 |
this.scribe.space(); |
3029 |
this.scribe.space(); |
3035 |
this.scribe.printQualifiedReference(compilationUnitDeclaration.currentPackage.sourceEnd, false/*do not expect parenthesis*/); |
3030 |
this.scribe.printQualifiedReference(compilationUnitDeclaration.currentPackage.sourceEnd, false/*do not expect parenthesis*/); |
3036 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3031 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3037 |
this.scribe.printTrailingComment(); |
3032 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
3038 |
int blankLinesAfterPackage = this.preferences.blank_lines_after_package; |
3033 |
int blankLinesAfterPackage = this.preferences.blank_lines_after_package; |
3039 |
if (blankLinesAfterPackage > 0) { |
3034 |
if (blankLinesAfterPackage > 0) { |
3040 |
this.scribe.printEmptyLines(blankLinesAfterPackage); |
3035 |
this.scribe.printEmptyLines(blankLinesAfterPackage); |
Lines 3057-3074
Link Here
|
3057 |
} |
3052 |
} |
3058 |
} |
3053 |
} |
3059 |
int importLength = imports.length; |
3054 |
int importLength = imports.length; |
3060 |
int savedNumberOfLineToPreserve = this.preferences.number_of_empty_lines_to_preserve; |
|
|
3061 |
if (importLength != 1) { |
3055 |
if (importLength != 1) { |
3062 |
format(imports[0], false); |
3056 |
format(imports[0], false); |
3063 |
for (int i = 1; i < importLength - 1; i++) { |
3057 |
for (int i = 1; i < importLength - 1; i++) { |
3064 |
format(imports[i], false); |
3058 |
format(imports[i], false); |
3065 |
} |
3059 |
} |
3066 |
format(imports[importLength - 1], true); |
3060 |
format(imports[importLength - 1], true); |
3067 |
this.preferences.number_of_empty_lines_to_preserve = savedNumberOfLineToPreserve; |
|
|
3068 |
} else { |
3061 |
} else { |
3069 |
format(imports[0], true); |
3062 |
format(imports[0], true); |
3070 |
} |
3063 |
} |
3071 |
this.preferences.number_of_empty_lines_to_preserve = savedNumberOfLineToPreserve; |
|
|
3072 |
|
3064 |
|
3073 |
int blankLinesAfterImports = this.preferences.blank_lines_after_imports; |
3065 |
int blankLinesAfterImports = this.preferences.blank_lines_after_imports; |
3074 |
if (blankLinesAfterImports > 0) { |
3066 |
if (blankLinesAfterImports > 0) { |
Lines 3205-3211
Link Here
|
3205 |
this.scribe.space(); |
3197 |
this.scribe.space(); |
3206 |
} |
3198 |
} |
3207 |
conditionalExpression.valueIfTrue.traverse(this, scope); |
3199 |
conditionalExpression.valueIfTrue.traverse(this, scope); |
3208 |
this.scribe.printTrailingComment(); |
3200 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
3209 |
this.scribe.alignFragment(conditionalExpressionAlignment, 1); |
3201 |
this.scribe.alignFragment(conditionalExpressionAlignment, 1); |
3210 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOLON, this.preferences.insert_space_before_colon_in_conditional); |
3202 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOLON, this.preferences.insert_space_before_colon_in_conditional); |
3211 |
|
3203 |
|
Lines 3241-3247
Link Here
|
3241 |
this.scribe.printIndentationIfNecessary(); |
3233 |
this.scribe.printIndentationIfNecessary(); |
3242 |
} |
3234 |
} |
3243 |
this.scribe.scanner.resetTo(constructorDeclaration.declarationSourceEnd + 1, this.scribe.scannerEndPosition - 1); |
3235 |
this.scribe.scanner.resetTo(constructorDeclaration.declarationSourceEnd + 1, this.scribe.scannerEndPosition - 1); |
3244 |
this.scribe.printTrailingComment(); |
3236 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
3245 |
switch(this.scribe.scanner.source[this.scribe.scanner.currentPosition]) { |
3237 |
switch(this.scribe.scanner.source[this.scribe.scanner.currentPosition]) { |
3246 |
case '\n' : |
3238 |
case '\n' : |
3247 |
this.scribe.scanner.currentPosition++; |
3239 |
this.scribe.scanner.currentPosition++; |
Lines 3356-3369
Link Here
|
3356 |
} |
3348 |
} |
3357 |
} |
3349 |
} |
3358 |
this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE); |
3350 |
this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE); |
3359 |
this.scribe.printTrailingComment(); |
3351 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
3360 |
if (constructor_declaration_brace.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) { |
3352 |
if (constructor_declaration_brace.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) { |
3361 |
this.scribe.unIndent(); |
3353 |
this.scribe.unIndent(); |
3362 |
} |
3354 |
} |
3363 |
} else { |
3355 |
} else { |
3364 |
// no method body |
3356 |
// no method body |
3365 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3357 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3366 |
this.scribe.printTrailingComment(); |
3358 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
3367 |
} |
3359 |
} |
3368 |
return false; |
3360 |
return false; |
3369 |
} |
3361 |
} |
Lines 3378-3384
Link Here
|
3378 |
this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, true); |
3370 |
this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, true); |
3379 |
} |
3371 |
} |
3380 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3372 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3381 |
this.scribe.printTrailingComment(); |
3373 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
3382 |
return false; |
3374 |
return false; |
3383 |
} |
3375 |
} |
3384 |
|
3376 |
|
Lines 3407-3413
Link Here
|
3407 |
action.traverse(this, scope); |
3399 |
action.traverse(this, scope); |
3408 |
if (action instanceof Expression) { |
3400 |
if (action instanceof Expression) { |
3409 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3401 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3410 |
this.scribe.printTrailingComment(); |
3402 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
3411 |
} |
3403 |
} |
3412 |
this.scribe.printNewLine(); |
3404 |
this.scribe.printNewLine(); |
3413 |
this.scribe.unIndent(); |
3405 |
this.scribe.unIndent(); |
Lines 3433-3439
Link Here
|
3433 |
|
3425 |
|
3434 |
this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_while); |
3426 |
this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_while); |
3435 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3427 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3436 |
this.scribe.printTrailingComment(); |
3428 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
3437 |
return false; |
3429 |
return false; |
3438 |
} |
3430 |
} |
3439 |
|
3431 |
|
Lines 3466-3472
Link Here
|
3466 |
this.scribe.printNewLine(); |
3458 |
this.scribe.printNewLine(); |
3467 |
} |
3459 |
} |
3468 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3460 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3469 |
this.scribe.printTrailingComment(); |
3461 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
3470 |
return false; |
3462 |
return false; |
3471 |
} |
3463 |
} |
3472 |
// field is an enum constant |
3464 |
// field is an enum constant |
Lines 3519-3525
Link Here
|
3519 |
this.scribe.printNewLine(); |
3511 |
this.scribe.printNewLine(); |
3520 |
} |
3512 |
} |
3521 |
this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE); |
3513 |
this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE); |
3522 |
this.scribe.printTrailingComment(); |
3514 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
3523 |
if (enum_constant_brace.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) { |
3515 |
if (enum_constant_brace.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) { |
3524 |
this.scribe.unIndent(); |
3516 |
this.scribe.unIndent(); |
3525 |
} |
3517 |
} |
Lines 3605-3611
Link Here
|
3605 |
for (int i = 0; i < argumentLength; i++) { |
3597 |
for (int i = 0; i < argumentLength; i++) { |
3606 |
if (i > 0) { |
3598 |
if (i > 0) { |
3607 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_explicit_constructor_call_arguments); |
3599 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_explicit_constructor_call_arguments); |
3608 |
this.scribe.printTrailingComment(); |
3600 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
3609 |
} |
3601 |
} |
3610 |
this.scribe.alignFragment(argumentsAlignment, i); |
3602 |
this.scribe.alignFragment(argumentsAlignment, i); |
3611 |
if (i > 0 && this.preferences.insert_space_after_comma_in_explicit_constructor_call_arguments) { |
3603 |
if (i > 0 && this.preferences.insert_space_after_comma_in_explicit_constructor_call_arguments) { |
Lines 3624-3630
Link Here
|
3624 |
this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_between_empty_parens_in_method_invocation); |
3616 |
this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_between_empty_parens_in_method_invocation); |
3625 |
} |
3617 |
} |
3626 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3618 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3627 |
this.scribe.printTrailingComment(); |
3619 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
3628 |
return false; |
3620 |
return false; |
3629 |
} |
3621 |
} |
3630 |
/** |
3622 |
/** |
Lines 3718-3724
Link Here
|
3718 |
} |
3710 |
} |
3719 |
if (action instanceof Expression) { |
3711 |
if (action instanceof Expression) { |
3720 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3712 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3721 |
this.scribe.printTrailingComment(); |
3713 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
3722 |
} |
3714 |
} |
3723 |
} else { |
3715 |
} else { |
3724 |
/* |
3716 |
/* |
Lines 3754-3760
Link Here
|
3754 |
if (this.preferences.insert_space_after_comma_in_for_inits) { |
3746 |
if (this.preferences.insert_space_after_comma_in_for_inits) { |
3755 |
this.scribe.space(); |
3747 |
this.scribe.space(); |
3756 |
} |
3748 |
} |
3757 |
this.scribe.printTrailingComment(); |
3749 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
3758 |
} |
3750 |
} |
3759 |
} |
3751 |
} |
3760 |
} |
3752 |
} |
Lines 3780-3786
Link Here
|
3780 |
if (this.preferences.insert_space_after_comma_in_for_increments) { |
3772 |
if (this.preferences.insert_space_after_comma_in_for_increments) { |
3781 |
this.scribe.space(); |
3773 |
this.scribe.space(); |
3782 |
} |
3774 |
} |
3783 |
this.scribe.printTrailingComment(); |
3775 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
3784 |
} |
3776 |
} |
3785 |
} |
3777 |
} |
3786 |
} |
3778 |
} |
Lines 3804-3810
Link Here
|
3804 |
} |
3796 |
} |
3805 |
if (action instanceof Expression) { |
3797 |
if (action instanceof Expression) { |
3806 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3798 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3807 |
this.scribe.printTrailingComment(); |
3799 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
3808 |
} |
3800 |
} |
3809 |
} else { |
3801 |
} else { |
3810 |
/* |
3802 |
/* |
Lines 3869-3875
Link Here
|
3869 |
thenStatement.traverse(this, scope); |
3861 |
thenStatement.traverse(this, scope); |
3870 |
if (thenStatement instanceof Expression) { |
3862 |
if (thenStatement instanceof Expression) { |
3871 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3863 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3872 |
this.scribe.printTrailingComment(); |
3864 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
3873 |
} |
3865 |
} |
3874 |
ok = true; |
3866 |
ok = true; |
3875 |
} catch (AlignmentException e) { |
3867 |
} catch (AlignmentException e) { |
Lines 3882-3900
Link Here
|
3882 |
thenStatement.traverse(this, scope); |
3874 |
thenStatement.traverse(this, scope); |
3883 |
if (thenStatement instanceof Expression) { |
3875 |
if (thenStatement instanceof Expression) { |
3884 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3876 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3885 |
this.scribe.printTrailingComment(); |
3877 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
3886 |
} |
3878 |
} |
3887 |
if (elseStatement != null) { |
3879 |
if (elseStatement != null) { |
3888 |
this.scribe.printNewLine(); |
3880 |
this.scribe.printNewLine(); |
3889 |
} |
3881 |
} |
3890 |
} else { |
3882 |
} else { |
3891 |
this.scribe.printTrailingComment(); |
3883 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
3892 |
this.scribe.printNewLine(); |
3884 |
this.scribe.printNewLine(); |
3893 |
this.scribe.indent(); |
3885 |
this.scribe.indent(); |
3894 |
thenStatement.traverse(this, scope); |
3886 |
thenStatement.traverse(this, scope); |
3895 |
if (thenStatement instanceof Expression) { |
3887 |
if (thenStatement instanceof Expression) { |
3896 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3888 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3897 |
this.scribe.printTrailingComment(); |
3889 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
3898 |
} |
3890 |
} |
3899 |
if (elseStatement != null) { |
3891 |
if (elseStatement != null) { |
3900 |
this.scribe.printNewLine(); |
3892 |
this.scribe.printNewLine(); |
Lines 3926-3932
Link Here
|
3926 |
elseStatement.traverse(this, scope); |
3918 |
elseStatement.traverse(this, scope); |
3927 |
if (elseStatement instanceof Expression) { |
3919 |
if (elseStatement instanceof Expression) { |
3928 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3920 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3929 |
this.scribe.printTrailingComment(); |
3921 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
3930 |
} |
3922 |
} |
3931 |
} else { |
3923 |
} else { |
3932 |
this.scribe.printNewLine(); |
3924 |
this.scribe.printNewLine(); |
Lines 3934-3940
Link Here
|
3934 |
elseStatement.traverse(this, scope); |
3926 |
elseStatement.traverse(this, scope); |
3935 |
if (elseStatement instanceof Expression) { |
3927 |
if (elseStatement instanceof Expression) { |
3936 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3928 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
3937 |
this.scribe.printTrailingComment(); |
3929 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
3938 |
} |
3930 |
} |
3939 |
this.scribe.unIndent(); |
3931 |
this.scribe.unIndent(); |
3940 |
} |
3932 |
} |
Lines 4011-4017
Link Here
|
4011 |
statement.traverse(this, scope); |
4003 |
statement.traverse(this, scope); |
4012 |
if (statement instanceof Expression) { |
4004 |
if (statement instanceof Expression) { |
4013 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
4005 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
4014 |
this.scribe.printTrailingComment(); |
4006 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
4015 |
} |
4007 |
} |
4016 |
return false; |
4008 |
return false; |
4017 |
} |
4009 |
} |
Lines 4125-4131
Link Here
|
4125 |
this.scribe.printIndentationIfNecessary(); |
4117 |
this.scribe.printIndentationIfNecessary(); |
4126 |
} |
4118 |
} |
4127 |
this.scribe.scanner.resetTo(methodDeclaration.declarationSourceEnd + 1, this.scribe.scannerEndPosition - 1); |
4119 |
this.scribe.scanner.resetTo(methodDeclaration.declarationSourceEnd + 1, this.scribe.scannerEndPosition - 1); |
4128 |
this.scribe.printTrailingComment(); |
4120 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
4129 |
if (!this.scribe.scanner.atEnd()) { |
4121 |
if (!this.scribe.scanner.atEnd()) { |
4130 |
switch(this.scribe.scanner.source[this.scribe.scanner.currentPosition]) { |
4122 |
switch(this.scribe.scanner.source[this.scribe.scanner.currentPosition]) { |
4131 |
case '\n' : |
4123 |
case '\n' : |
Lines 4255-4268
Link Here
|
4255 |
} |
4247 |
} |
4256 |
} |
4248 |
} |
4257 |
this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE); |
4249 |
this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE); |
4258 |
this.scribe.printTrailingComment(); |
4250 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
4259 |
if (method_declaration_brace.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) { |
4251 |
if (method_declaration_brace.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) { |
4260 |
this.scribe.unIndent(); |
4252 |
this.scribe.unIndent(); |
4261 |
} |
4253 |
} |
4262 |
} else { |
4254 |
} else { |
4263 |
// no method body |
4255 |
// no method body |
4264 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
4256 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
4265 |
this.scribe.printTrailingComment(); |
4257 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
4266 |
} |
4258 |
} |
4267 |
return false; |
4259 |
return false; |
4268 |
} |
4260 |
} |
Lines 4621-4627
Link Here
|
4621 |
for (int i = 0; i < argumentLength; i++) { |
4613 |
for (int i = 0; i < argumentLength; i++) { |
4622 |
if (i > 0) { |
4614 |
if (i > 0) { |
4623 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_allocation_expression); |
4615 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_allocation_expression); |
4624 |
this.scribe.printTrailingComment(); |
4616 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
4625 |
} |
4617 |
} |
4626 |
this.scribe.alignFragment(argumentsAlignment, i); |
4618 |
this.scribe.alignFragment(argumentsAlignment, i); |
4627 |
if (i > 0 && this.preferences.insert_space_after_comma_in_allocation_expression) { |
4619 |
if (i > 0 && this.preferences.insert_space_after_comma_in_allocation_expression) { |
Lines 4768-4774
Link Here
|
4768 |
* Print the semi-colon |
4760 |
* Print the semi-colon |
4769 |
*/ |
4761 |
*/ |
4770 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
4762 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
4771 |
this.scribe.printTrailingComment(); |
4763 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
4772 |
return false; |
4764 |
return false; |
4773 |
} |
4765 |
} |
4774 |
public boolean visit(SingleMemberAnnotation annotation, BlockScope scope) { |
4766 |
public boolean visit(SingleMemberAnnotation annotation, BlockScope scope) { |
Lines 4850-4856
Link Here
|
4850 |
} |
4842 |
} |
4851 |
this.scribe.checkNLSTag(stringLiteral.sourceStart); |
4843 |
this.scribe.checkNLSTag(stringLiteral.sourceStart); |
4852 |
this.scribe.printNextToken(TerminalTokens.TokenNameStringLiteral); |
4844 |
this.scribe.printNextToken(TerminalTokens.TokenNameStringLiteral); |
4853 |
this.scribe.printTrailingComment(); |
4845 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
4854 |
if (numberOfParens > 0) { |
4846 |
if (numberOfParens > 0) { |
4855 |
manageClosingParenthesizedExpression(stringLiteral, numberOfParens); |
4847 |
manageClosingParenthesizedExpression(stringLiteral, numberOfParens); |
4856 |
} |
4848 |
} |
Lines 4877-4885
Link Here
|
4877 |
for (int i = 0; i < fragmentsSize - 1; i++) { |
4869 |
for (int i = 0; i < fragmentsSize - 1; i++) { |
4878 |
ASTNode fragment = fragments[i]; |
4870 |
ASTNode fragment = fragments[i]; |
4879 |
fragment.traverse(this, scope); |
4871 |
fragment.traverse(this, scope); |
4880 |
this.scribe.printTrailingComment(); |
4872 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
4881 |
if (this.scribe.lastNumberOfNewLines == 1) { |
4873 |
if (this.scribe.lastNumberOfNewLines == 1) { |
4882 |
// a new line has been inserted by printTrailingComment() |
4874 |
// a new line has been inserted by printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT) |
4883 |
this.scribe.indentationLevel = binaryExpressionAlignment.breakIndentationLevel; |
4875 |
this.scribe.indentationLevel = binaryExpressionAlignment.breakIndentationLevel; |
4884 |
} |
4876 |
} |
4885 |
this.scribe.alignFragment(binaryExpressionAlignment, i); |
4877 |
this.scribe.alignFragment(binaryExpressionAlignment, i); |
Lines 4889-4895
Link Here
|
4889 |
} |
4881 |
} |
4890 |
} |
4882 |
} |
4891 |
fragments[fragmentsSize - 1].traverse(this, scope); |
4883 |
fragments[fragmentsSize - 1].traverse(this, scope); |
4892 |
this.scribe.printTrailingComment(); |
4884 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
4893 |
ok = true; |
4885 |
ok = true; |
4894 |
} catch(AlignmentException e){ |
4886 |
} catch(AlignmentException e){ |
4895 |
this.scribe.redoAlignment(e); |
4887 |
this.scribe.redoAlignment(e); |
Lines 4959-4965
Link Here
|
4959 |
this.scribe.unIndent(); |
4951 |
this.scribe.unIndent(); |
4960 |
} |
4952 |
} |
4961 |
statement.traverse(this, scope); |
4953 |
statement.traverse(this, scope); |
4962 |
this.scribe.printTrailingComment(); |
4954 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
4963 |
wasACase = true; |
4955 |
wasACase = true; |
4964 |
wasAStatement = false; |
4956 |
wasAStatement = false; |
4965 |
if (this.preferences.indent_switchstatements_compare_to_cases) { |
4957 |
if (this.preferences.indent_switchstatements_compare_to_cases) { |
Lines 5017-5023
Link Here
|
5017 |
* Print the semi-colon |
5009 |
* Print the semi-colon |
5018 |
*/ |
5010 |
*/ |
5019 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
5011 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
5020 |
this.scribe.printTrailingComment(); |
5012 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
5021 |
this.scribe.printNewLine(); |
5013 |
this.scribe.printNewLine(); |
5022 |
} else if (statement instanceof LocalDeclaration) { |
5014 |
} else if (statement instanceof LocalDeclaration) { |
5023 |
LocalDeclaration currentLocal = (LocalDeclaration) statement; |
5015 |
LocalDeclaration currentLocal = (LocalDeclaration) statement; |
Lines 5032-5038
Link Here
|
5032 |
* Print the semi-colon |
5024 |
* Print the semi-colon |
5033 |
*/ |
5025 |
*/ |
5034 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
5026 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
5035 |
this.scribe.printTrailingComment(); |
5027 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
5036 |
this.scribe.printNewLine(); |
5028 |
this.scribe.printNewLine(); |
5037 |
} |
5029 |
} |
5038 |
} else { |
5030 |
} else { |
Lines 5040-5046
Link Here
|
5040 |
* Print the semi-colon |
5032 |
* Print the semi-colon |
5041 |
*/ |
5033 |
*/ |
5042 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
5034 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
5043 |
this.scribe.printTrailingComment(); |
5035 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
5044 |
this.scribe.printNewLine(); |
5036 |
this.scribe.printNewLine(); |
5045 |
} |
5037 |
} |
5046 |
} else { |
5038 |
} else { |
Lines 5048-5054
Link Here
|
5048 |
* Print the semi-colon |
5040 |
* Print the semi-colon |
5049 |
*/ |
5041 |
*/ |
5050 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
5042 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
5051 |
this.scribe.printTrailingComment(); |
5043 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
5052 |
this.scribe.printNewLine(); |
5044 |
this.scribe.printNewLine(); |
5053 |
} |
5045 |
} |
5054 |
} else if (!wasACase) { |
5046 |
} else if (!wasACase) { |
Lines 5066-5072
Link Here
|
5066 |
} |
5058 |
} |
5067 |
this.scribe.printNewLine(); |
5059 |
this.scribe.printNewLine(); |
5068 |
this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE); |
5060 |
this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE); |
5069 |
this.scribe.printTrailingComment(); |
5061 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
5070 |
if (switch_brace.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) { |
5062 |
if (switch_brace.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) { |
5071 |
this.scribe.unIndent(); |
5063 |
this.scribe.unIndent(); |
5072 |
} |
5064 |
} |
Lines 5133-5139
Link Here
|
5133 |
* Print the semi-colon |
5125 |
* Print the semi-colon |
5134 |
*/ |
5126 |
*/ |
5135 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
5127 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
5136 |
this.scribe.printTrailingComment(); |
5128 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
5137 |
return false; |
5129 |
return false; |
5138 |
} |
5130 |
} |
5139 |
|
5131 |
|
Lines 5385-5391
Link Here
|
5385 |
action.traverse(this, scope); |
5377 |
action.traverse(this, scope); |
5386 |
if (action instanceof Expression) { |
5378 |
if (action instanceof Expression) { |
5387 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
5379 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
5388 |
this.scribe.printTrailingComment(); |
5380 |
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); |
5389 |
} |
5381 |
} |
5390 |
this.scribe.unIndent(); |
5382 |
this.scribe.unIndent(); |
5391 |
} |
5383 |
} |