Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 59285 Details for
Bug 124622
[formatter] Comments in switch-case wrong aligned in some cases
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Proposed fix
patch_124622.txt (text/plain), 6.97 KB, created by
Olivier Thomann
on 2007-02-19 12:33:34 EST
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2007-02-19 12:33:34 EST
Size:
6.97 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java,v >retrieving revision 1.195 >diff -u -r1.195 CodeFormatterVisitor.java >--- formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java 8 Feb 2007 15:14:04 -0000 1.195 >+++ formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java 19 Feb 2007 17:31:34 -0000 >@@ -4861,95 +4861,85 @@ > } > final Statement[] statements = switchStatement.statements; > boolean wasACase = false; >- boolean wasAStatement = false; > if (statements != null) { > int statementsLength = statements.length; > for (int i = 0; i < statementsLength; i++) { > final Statement statement = statements[i]; > if (statement instanceof CaseStatement) { > if (wasACase) { >- this.scribe.printNewLine(); >- } >- if ((wasACase && this.preferences.indent_switchstatements_compare_to_cases) >- || (wasAStatement && this.preferences.indent_switchstatements_compare_to_cases)) { >- this.scribe.unIndent(); >+ if (this.hasComments()) { >+ if (this.preferences.indent_breaks_compare_to_cases) { >+ this.scribe.indent(); >+ } >+ this.scribe.printComment(); >+ if (this.preferences.indent_breaks_compare_to_cases) { >+ this.scribe.unIndent(); >+ } >+ } > } >+ this.scribe.printNewLine(); > statement.traverse(this, scope); > this.scribe.printTrailingComment(); > wasACase = true; >- wasAStatement = false; >- if (this.preferences.indent_switchstatements_compare_to_cases) { >- this.scribe.indent(); >- } > } else if (statement instanceof BreakStatement) { >+ this.scribe.printNewLine(); > if (this.preferences.indent_breaks_compare_to_cases) { >- if (wasAStatement && !this.preferences.indent_switchstatements_compare_to_cases) { >- this.scribe.indent(); >- } >- } else { >- if (wasAStatement) { >- if (this.preferences.indent_switchstatements_compare_to_cases) { >- this.scribe.unIndent(); >- } >- } >- if (wasACase && this.preferences.indent_switchstatements_compare_to_cases) { >- this.scribe.unIndent(); >- } >- } >- if (wasACase) { >- this.scribe.printNewLine(); >+ this.scribe.indent(); > } >+ this.scribe.printComment(); > statement.traverse(this, scope); >+ this.scribe.printComment(); > if (this.preferences.indent_breaks_compare_to_cases) { > this.scribe.unIndent(); > } > wasACase = false; >- wasAStatement = false; > } else if (statement instanceof Block) { >+ this.scribe.printComment(); > String bracePosition; > if (wasACase) { >- if (this.preferences.indent_switchstatements_compare_to_cases) { >- this.scribe.unIndent(); >- } > bracePosition = this.preferences.brace_position_for_block_in_case; > formatBlock((Block) statement, scope, bracePosition, this.preferences.insert_space_after_colon_in_case); >- if (this.preferences.indent_switchstatements_compare_to_cases) { >- this.scribe.indent(); >- } > } else { > bracePosition = this.preferences.brace_position_for_block; > formatBlock((Block) statement, scope, bracePosition, this.preferences.insert_space_before_opening_brace_in_block); > } >- wasAStatement = true; > wasACase = false; >+ this.scribe.printComment(); > } else { >+ if (this.preferences.indent_switchstatements_compare_to_cases) { >+ this.scribe.indent(); >+ } >+ this.scribe.printComment(); > this.scribe.printNewLine(); > statement.traverse(this, scope); >- wasAStatement = true; > wasACase = false; >- } >- if (statement instanceof Expression) { >- /* >- * Print the semi-colon >- */ >- this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); >- this.scribe.printTrailingComment(); >- this.scribe.printNewLine(); >- } else if (statement instanceof LocalDeclaration) { >- LocalDeclaration currentLocal = (LocalDeclaration) statement; >- if (i < (statementsLength - 1)) { >- /* >- * We need to check that the next statement is a local declaration >- */ >- if (statements[i + 1] instanceof LocalDeclaration) { >- LocalDeclaration nextLocal = (LocalDeclaration) statements[i + 1]; >- if (currentLocal.declarationSourceStart != nextLocal.declarationSourceStart) { >+ if (statement instanceof Expression) { >+ /* >+ * Print the semi-colon >+ */ >+ this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); >+ this.scribe.printTrailingComment(); >+ } else if (statement instanceof LocalDeclaration) { >+ LocalDeclaration currentLocal = (LocalDeclaration) statement; >+ if (i < (statementsLength - 1)) { >+ /* >+ * We need to check that the next statement is a local declaration >+ */ >+ if (statements[i + 1] instanceof LocalDeclaration) { >+ LocalDeclaration nextLocal = (LocalDeclaration) statements[i + 1]; >+ if (currentLocal.declarationSourceStart != nextLocal.declarationSourceStart) { >+ /* >+ * Print the semi-colon >+ */ >+ this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); >+ this.scribe.printTrailingComment(); >+ } >+ } else { > /* > * Print the semi-colon > */ > this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); > this.scribe.printTrailingComment(); >- this.scribe.printNewLine(); > } > } else { > /* >@@ -4957,26 +4947,16 @@ > */ > this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); > this.scribe.printTrailingComment(); >- this.scribe.printNewLine(); > } >- } else { >- /* >- * Print the semi-colon >- */ >- this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); >- this.scribe.printTrailingComment(); >- this.scribe.printNewLine(); > } >- } else if (!wasACase) { >+ this.scribe.printComment(); >+ if (this.preferences.indent_switchstatements_compare_to_cases) { >+ this.scribe.unIndent(); >+ } > this.scribe.printNewLine(); > } >- this.scribe.printComment(); > } > } >- >- if ((wasACase || wasAStatement) && this.preferences.indent_switchstatements_compare_to_cases) { >- this.scribe.unIndent(); >- } > if (this.preferences.indent_switchstatements_compare_to_switch) { > this.scribe.unIndent(); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 124622
: 59285 |
59286