|
Lines 4861-4955
Link Here
|
| 4861 |
} |
4861 |
} |
| 4862 |
final Statement[] statements = switchStatement.statements; |
4862 |
final Statement[] statements = switchStatement.statements; |
| 4863 |
boolean wasACase = false; |
4863 |
boolean wasACase = false; |
| 4864 |
boolean wasAStatement = false; |
|
|
| 4865 |
if (statements != null) { |
4864 |
if (statements != null) { |
| 4866 |
int statementsLength = statements.length; |
4865 |
int statementsLength = statements.length; |
| 4867 |
for (int i = 0; i < statementsLength; i++) { |
4866 |
for (int i = 0; i < statementsLength; i++) { |
| 4868 |
final Statement statement = statements[i]; |
4867 |
final Statement statement = statements[i]; |
| 4869 |
if (statement instanceof CaseStatement) { |
4868 |
if (statement instanceof CaseStatement) { |
| 4870 |
if (wasACase) { |
4869 |
if (wasACase) { |
| 4871 |
this.scribe.printNewLine(); |
4870 |
if (this.hasComments()) { |
| 4872 |
} |
4871 |
if (this.preferences.indent_breaks_compare_to_cases) { |
| 4873 |
if ((wasACase && this.preferences.indent_switchstatements_compare_to_cases) |
4872 |
this.scribe.indent(); |
| 4874 |
|| (wasAStatement && this.preferences.indent_switchstatements_compare_to_cases)) { |
4873 |
} |
| 4875 |
this.scribe.unIndent(); |
4874 |
this.scribe.printComment(); |
|
|
4875 |
if (this.preferences.indent_breaks_compare_to_cases) { |
| 4876 |
this.scribe.unIndent(); |
| 4877 |
} |
| 4878 |
} |
| 4876 |
} |
4879 |
} |
|
|
4880 |
this.scribe.printNewLine(); |
| 4877 |
statement.traverse(this, scope); |
4881 |
statement.traverse(this, scope); |
| 4878 |
this.scribe.printTrailingComment(); |
4882 |
this.scribe.printTrailingComment(); |
| 4879 |
wasACase = true; |
4883 |
wasACase = true; |
| 4880 |
wasAStatement = false; |
|
|
| 4881 |
if (this.preferences.indent_switchstatements_compare_to_cases) { |
| 4882 |
this.scribe.indent(); |
| 4883 |
} |
| 4884 |
} else if (statement instanceof BreakStatement) { |
4884 |
} else if (statement instanceof BreakStatement) { |
|
|
4885 |
this.scribe.printNewLine(); |
| 4885 |
if (this.preferences.indent_breaks_compare_to_cases) { |
4886 |
if (this.preferences.indent_breaks_compare_to_cases) { |
| 4886 |
if (wasAStatement && !this.preferences.indent_switchstatements_compare_to_cases) { |
4887 |
this.scribe.indent(); |
| 4887 |
this.scribe.indent(); |
|
|
| 4888 |
} |
| 4889 |
} else { |
| 4890 |
if (wasAStatement) { |
| 4891 |
if (this.preferences.indent_switchstatements_compare_to_cases) { |
| 4892 |
this.scribe.unIndent(); |
| 4893 |
} |
| 4894 |
} |
| 4895 |
if (wasACase && this.preferences.indent_switchstatements_compare_to_cases) { |
| 4896 |
this.scribe.unIndent(); |
| 4897 |
} |
| 4898 |
} |
| 4899 |
if (wasACase) { |
| 4900 |
this.scribe.printNewLine(); |
| 4901 |
} |
4888 |
} |
|
|
4889 |
this.scribe.printComment(); |
| 4902 |
statement.traverse(this, scope); |
4890 |
statement.traverse(this, scope); |
|
|
4891 |
this.scribe.printComment(); |
| 4903 |
if (this.preferences.indent_breaks_compare_to_cases) { |
4892 |
if (this.preferences.indent_breaks_compare_to_cases) { |
| 4904 |
this.scribe.unIndent(); |
4893 |
this.scribe.unIndent(); |
| 4905 |
} |
4894 |
} |
| 4906 |
wasACase = false; |
4895 |
wasACase = false; |
| 4907 |
wasAStatement = false; |
|
|
| 4908 |
} else if (statement instanceof Block) { |
4896 |
} else if (statement instanceof Block) { |
|
|
4897 |
this.scribe.printComment(); |
| 4909 |
String bracePosition; |
4898 |
String bracePosition; |
| 4910 |
if (wasACase) { |
4899 |
if (wasACase) { |
| 4911 |
if (this.preferences.indent_switchstatements_compare_to_cases) { |
|
|
| 4912 |
this.scribe.unIndent(); |
| 4913 |
} |
| 4914 |
bracePosition = this.preferences.brace_position_for_block_in_case; |
4900 |
bracePosition = this.preferences.brace_position_for_block_in_case; |
| 4915 |
formatBlock((Block) statement, scope, bracePosition, this.preferences.insert_space_after_colon_in_case); |
4901 |
formatBlock((Block) statement, scope, bracePosition, this.preferences.insert_space_after_colon_in_case); |
| 4916 |
if (this.preferences.indent_switchstatements_compare_to_cases) { |
|
|
| 4917 |
this.scribe.indent(); |
| 4918 |
} |
| 4919 |
} else { |
4902 |
} else { |
| 4920 |
bracePosition = this.preferences.brace_position_for_block; |
4903 |
bracePosition = this.preferences.brace_position_for_block; |
| 4921 |
formatBlock((Block) statement, scope, bracePosition, this.preferences.insert_space_before_opening_brace_in_block); |
4904 |
formatBlock((Block) statement, scope, bracePosition, this.preferences.insert_space_before_opening_brace_in_block); |
| 4922 |
} |
4905 |
} |
| 4923 |
wasAStatement = true; |
|
|
| 4924 |
wasACase = false; |
4906 |
wasACase = false; |
|
|
4907 |
this.scribe.printComment(); |
| 4925 |
} else { |
4908 |
} else { |
|
|
4909 |
if (this.preferences.indent_switchstatements_compare_to_cases) { |
| 4910 |
this.scribe.indent(); |
| 4911 |
} |
| 4912 |
this.scribe.printComment(); |
| 4926 |
this.scribe.printNewLine(); |
4913 |
this.scribe.printNewLine(); |
| 4927 |
statement.traverse(this, scope); |
4914 |
statement.traverse(this, scope); |
| 4928 |
wasAStatement = true; |
|
|
| 4929 |
wasACase = false; |
4915 |
wasACase = false; |
| 4930 |
} |
4916 |
if (statement instanceof Expression) { |
| 4931 |
if (statement instanceof Expression) { |
4917 |
/* |
| 4932 |
/* |
4918 |
* Print the semi-colon |
| 4933 |
* Print the semi-colon |
4919 |
*/ |
| 4934 |
*/ |
4920 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
| 4935 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
4921 |
this.scribe.printTrailingComment(); |
| 4936 |
this.scribe.printTrailingComment(); |
4922 |
} else if (statement instanceof LocalDeclaration) { |
| 4937 |
this.scribe.printNewLine(); |
4923 |
LocalDeclaration currentLocal = (LocalDeclaration) statement; |
| 4938 |
} else if (statement instanceof LocalDeclaration) { |
4924 |
if (i < (statementsLength - 1)) { |
| 4939 |
LocalDeclaration currentLocal = (LocalDeclaration) statement; |
4925 |
/* |
| 4940 |
if (i < (statementsLength - 1)) { |
4926 |
* We need to check that the next statement is a local declaration |
| 4941 |
/* |
4927 |
*/ |
| 4942 |
* We need to check that the next statement is a local declaration |
4928 |
if (statements[i + 1] instanceof LocalDeclaration) { |
| 4943 |
*/ |
4929 |
LocalDeclaration nextLocal = (LocalDeclaration) statements[i + 1]; |
| 4944 |
if (statements[i + 1] instanceof LocalDeclaration) { |
4930 |
if (currentLocal.declarationSourceStart != nextLocal.declarationSourceStart) { |
| 4945 |
LocalDeclaration nextLocal = (LocalDeclaration) statements[i + 1]; |
4931 |
/* |
| 4946 |
if (currentLocal.declarationSourceStart != nextLocal.declarationSourceStart) { |
4932 |
* Print the semi-colon |
|
|
4933 |
*/ |
| 4934 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
| 4935 |
this.scribe.printTrailingComment(); |
| 4936 |
} |
| 4937 |
} else { |
| 4947 |
/* |
4938 |
/* |
| 4948 |
* Print the semi-colon |
4939 |
* Print the semi-colon |
| 4949 |
*/ |
4940 |
*/ |
| 4950 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
4941 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
| 4951 |
this.scribe.printTrailingComment(); |
4942 |
this.scribe.printTrailingComment(); |
| 4952 |
this.scribe.printNewLine(); |
|
|
| 4953 |
} |
4943 |
} |
| 4954 |
} else { |
4944 |
} else { |
| 4955 |
/* |
4945 |
/* |
|
Lines 4957-4982
Link Here
|
| 4957 |
*/ |
4947 |
*/ |
| 4958 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
4948 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
| 4959 |
this.scribe.printTrailingComment(); |
4949 |
this.scribe.printTrailingComment(); |
| 4960 |
this.scribe.printNewLine(); |
|
|
| 4961 |
} |
4950 |
} |
| 4962 |
} else { |
|
|
| 4963 |
/* |
| 4964 |
* Print the semi-colon |
| 4965 |
*/ |
| 4966 |
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); |
| 4967 |
this.scribe.printTrailingComment(); |
| 4968 |
this.scribe.printNewLine(); |
| 4969 |
} |
4951 |
} |
| 4970 |
} else if (!wasACase) { |
4952 |
this.scribe.printComment(); |
|
|
4953 |
if (this.preferences.indent_switchstatements_compare_to_cases) { |
| 4954 |
this.scribe.unIndent(); |
| 4955 |
} |
| 4971 |
this.scribe.printNewLine(); |
4956 |
this.scribe.printNewLine(); |
| 4972 |
} |
4957 |
} |
| 4973 |
this.scribe.printComment(); |
|
|
| 4974 |
} |
4958 |
} |
| 4975 |
} |
4959 |
} |
| 4976 |
|
|
|
| 4977 |
if ((wasACase || wasAStatement) && this.preferences.indent_switchstatements_compare_to_cases) { |
| 4978 |
this.scribe.unIndent(); |
| 4979 |
} |
| 4980 |
if (this.preferences.indent_switchstatements_compare_to_switch) { |
4960 |
if (this.preferences.indent_switchstatements_compare_to_switch) { |
| 4981 |
this.scribe.unIndent(); |
4961 |
this.scribe.unIndent(); |
| 4982 |
} |
4962 |
} |