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 150464 Details for
Bug 286601
[formatter] Code formatter formats anonymous inner classes wrongly when 'Never join lines' is on
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
New additional patch
v12.txt (text/plain), 49.81 KB, created by
Frederic Fusier
on 2009-10-25 10:20:10 EDT
(
hide
)
Description:
New additional patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2009-10-25 10:20:10 EDT
Size:
49.81 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.219 >diff -u -r1.219 CodeFormatterVisitor.java >--- formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java 8 Oct 2009 15:01:41 -0000 1.219 >+++ formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java 25 Oct 2009 14:13:06 -0000 >@@ -597,7 +597,7 @@ > if (this.preferences.insert_space_after_assignment_operator) { > this.scribe.space(); > } >- Alignment assignmentAlignment = this.scribe.createAlignment("fieldDeclarationAssignmentAlignment", this.preferences.alignment_for_assignment, Alignment.R_OUTERMOST, 1, this.scribe.scanner.currentPosition); //$NON-NLS-1$ >+ Alignment assignmentAlignment = this.scribe.createAlignment("fieldDeclarationAssignmentAlignment", this.preferences.alignment_for_assignment, Alignment.R_INNERMOST, 1, this.scribe.scanner.currentPosition); //$NON-NLS-1$ > this.scribe.enterAlignment(assignmentAlignment); > boolean ok = false; > do { >@@ -1088,7 +1088,7 @@ > space_before_opening_brace = this.preferences.insert_space_before_opening_brace_in_type_declaration; > break; > } >- formatLeftCurlyBrace(line, class_declaration_brace, true /* print comment */); >+ formatLeftCurlyBrace(line, class_declaration_brace); > formatTypeOpeningBrace(class_declaration_brace, space_before_opening_brace, typeDeclaration); > > boolean indent_body_declarations_compare_to_header; >@@ -1574,19 +1574,21 @@ > this.scribe.printTrailingComment(); > } > >- private void formatLeftCurlyBrace(final int line, final String bracePosition, boolean printComment) { >- >- if (printComment) { >- this.scribe.printComment(); >- } >- >+ private void formatLeftCurlyBrace(final int line, final String bracePosition) { >+ this.scribe.formatBrace = true; > /* > * deal with (quite unexpected) comments right before lcurly > */ >- if (DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP.equals(bracePosition) >- && (this.scribe.line > line || this.scribe.column >= this.preferences.page_width)) >- { >- this.scribe.printNewLine(); >+ try { >+ this.scribe.printComment(); >+ if (DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP.equals(bracePosition) >+ && (this.scribe.line > line || this.scribe.column >= this.preferences.page_width)) >+ { >+ this.scribe.printNewLine(); >+ } >+ } >+ finally { >+ this.scribe.formatBrace = false; > } > } > >@@ -1864,15 +1866,14 @@ > > private void formatOpeningBrace(String bracePosition, boolean insertSpaceBeforeBrace) { > >- if (DefaultCodeFormatterConstants.NEXT_LINE.equals(bracePosition)) { >- this.scribe.printNewLine(); >- } else if (DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(bracePosition)) { >- this.scribe.printNewLine(); >- this.scribe.indent(); >- } >- this.scribe.printNextToken(TerminalTokens.TokenNameLBRACE, insertSpaceBeforeBrace); >- >- this.scribe.printTrailingComment(); >+ if (DefaultCodeFormatterConstants.NEXT_LINE.equals(bracePosition)) { >+ this.scribe.printNewLine(); >+ } else if (DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(bracePosition)) { >+ this.scribe.printNewLine(); >+ this.scribe.indent(); >+ } >+ this.scribe.printNextToken(TerminalTokens.TokenNameLBRACE, insertSpaceBeforeBrace); >+ this.scribe.printTrailingComment(); > } > private void formatStatements(BlockScope scope, final Statement[] statements, boolean insertNewLineAfterLastStatement) { > int statementsLength = statements.length; >@@ -3317,7 +3318,7 @@ > * Method body > */ > String constructor_declaration_brace = this.preferences.brace_position_for_constructor_declaration; >- formatLeftCurlyBrace(line, constructor_declaration_brace, false /* do not print comment yet, it will be done on formatOpeningBrace */); >+ formatLeftCurlyBrace(line, constructor_declaration_brace); > formatOpeningBrace(constructor_declaration_brace, this.preferences.insert_space_before_opening_brace_in_constructor_declaration); > final int numberOfBlankLinesAtBeginningOfMethodBody = this.preferences.blank_lines_at_beginning_of_method_body; > if (numberOfBlankLinesAtBeginningOfMethodBody > 0) { >@@ -3393,7 +3394,7 @@ > final Statement action = doStatement.action; > if (action != null) { > if (action instanceof Block) { >- formatLeftCurlyBrace(line, this.preferences.brace_position_for_block, true /* print comment */); >+ formatLeftCurlyBrace(line, this.preferences.brace_position_for_block); > action.traverse(this, scope); > } else if (action instanceof EmptyStatement) { > /* >@@ -3499,7 +3500,7 @@ > */ > String enum_constant_brace = this.preferences.brace_position_for_enum_constant; > >- formatLeftCurlyBrace(line, enum_constant_brace, false /* do not print comment yet, it will be done on formatTypeOpeningBraceForEnumConstant */); >+ formatLeftCurlyBrace(line, enum_constant_brace); > formatTypeOpeningBraceForEnumConstant(enum_constant_brace, this.preferences.insert_space_before_opening_brace_in_enum_constant, typeDeclaration); > > if (this.preferences.indent_body_declarations_compare_to_enum_constant_header) { >@@ -3702,7 +3703,7 @@ > final Statement action = forStatement.action; > if (action != null) { > if (action instanceof Block) { >- formatLeftCurlyBrace(line, this.preferences.brace_position_for_block, true /* print comment */); >+ formatLeftCurlyBrace(line, this.preferences.brace_position_for_block); > action.traverse(this, scope); > } else if (action instanceof EmptyStatement) { > /* >@@ -3788,7 +3789,7 @@ > final Statement action = forStatement.action; > if (action != null) { > if (action instanceof Block) { >- formatLeftCurlyBrace(line, this.preferences.brace_position_for_block, true /* print comment */); >+ formatLeftCurlyBrace(line, this.preferences.brace_position_for_block); > action.traverse(this, scope); > } else if (action instanceof EmptyStatement) { > /* >@@ -3844,7 +3845,7 @@ > */ > formatGuardClauseBlock((Block) thenStatement, scope); > } else { >- formatLeftCurlyBrace(line, this.preferences.brace_position_for_block, true /* print comment */); >+ formatLeftCurlyBrace(line, this.preferences.brace_position_for_block); > thenStatement.traverse(this, scope); > if (elseStatement != null && (this.preferences.insert_new_line_before_else_in_if_statement)) { > this.scribe.printNewLine(); >@@ -4226,7 +4227,7 @@ > * Method body > */ > String method_declaration_brace = this.preferences.brace_position_for_method_declaration; >- formatLeftCurlyBrace(line, method_declaration_brace, false /* do not print comment yet, it will be done on formatOpeningBrace */); >+ formatLeftCurlyBrace(line, method_declaration_brace); > formatOpeningBrace(method_declaration_brace, this.preferences.insert_space_before_opening_brace_in_method_declaration); > final int numberOfBlankLinesAtBeginningOfMethodBody = this.preferences.blank_lines_at_beginning_of_method_body; > if (numberOfBlankLinesAtBeginningOfMethodBody > 0) { >@@ -4640,7 +4641,7 @@ > } > final TypeDeclaration anonymousType = qualifiedAllocationExpression.anonymousType; > if (anonymousType != null) { >- formatLeftCurlyBrace(line, this.preferences.brace_position_for_anonymous_type_declaration, false /* do not print comment yet, it will be done on formatAnonymousTypeDeclaration */); >+ formatLeftCurlyBrace(line, this.preferences.brace_position_for_anonymous_type_declaration); > formatAnonymousTypeDeclaration(anonymousType); > } > if (numberOfParens > 0) { >@@ -5092,7 +5093,7 @@ > > this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_synchronized); > >- formatLeftCurlyBrace(line, this.preferences.brace_position_for_block, true /* print comment */); >+ formatLeftCurlyBrace(line, this.preferences.brace_position_for_block); > synchronizedStatement.block.traverse(this, scope); > return false; > } >@@ -5177,7 +5178,7 @@ > > this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_catch); > >- formatLeftCurlyBrace(line, this.preferences.brace_position_for_block, true /* print comment */); >+ formatLeftCurlyBrace(line, this.preferences.brace_position_for_block); > tryStatement.catchBlocks[i].traverse(this, scope); > } > } >@@ -5371,7 +5372,7 @@ > final Statement action = whileStatement.action; > if (action != null) { > if (action instanceof Block) { >- formatLeftCurlyBrace(line, this.preferences.brace_position_for_block, true /* print comment */); >+ formatLeftCurlyBrace(line, this.preferences.brace_position_for_block); > action.traverse(this, scope); > } else if (action instanceof EmptyStatement) { > /* >Index: formatter/org/eclipse/jdt/internal/formatter/Location.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Location.java,v >retrieving revision 1.15 >diff -u -r1.15 Location.java >--- formatter/org/eclipse/jdt/internal/formatter/Location.java 21 Aug 2009 08:28:20 -0000 1.15 >+++ formatter/org/eclipse/jdt/internal/formatter/Location.java 25 Oct 2009 14:13:06 -0000 >@@ -53,4 +53,15 @@ > this.numberOfIndentations = scribe.numberOfIndentations; > this.textEdit = scribe.getLastEdit(); > } >+ >+ public String toString() { >+ StringBuffer buffer = new StringBuffer(); >+ buffer.append("output (column="+this.outputColumn); //$NON-NLS-1$ >+ buffer.append(", line="+this.outputLine); //$NON-NLS-1$ >+ buffer.append(", indentation level="+this.outputIndentationLevel); //$NON-NLS-1$ >+ buffer.append(") input (offset="+this.inputOffset); //$NON-NLS-1$ >+ buffer.append(", column="+this.inputColumn); //$NON-NLS-1$ >+ buffer.append(')'); >+ return buffer.toString(); >+ } > } >Index: formatter/org/eclipse/jdt/internal/formatter/Scribe.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java,v >retrieving revision 1.176 >diff -u -r1.176 Scribe.java >--- formatter/org/eclipse/jdt/internal/formatter/Scribe.java 24 Oct 2009 21:26:30 -0000 1.176 >+++ formatter/org/eclipse/jdt/internal/formatter/Scribe.java 25 Oct 2009 14:13:08 -0000 >@@ -72,6 +72,8 @@ > public CodeFormatterVisitor formatter; > public int indentationLevel; > public int lastNumberOfNewLines; >+ private boolean preserveLineBreakIndentation = false; >+ boolean formatBrace; > public int line; > > private int[] lineEnds; >@@ -274,8 +276,8 @@ > OptimizedReplaceEdit edit = null; > int overlapIndex = -1; > int linesOutside= -1; >- >- // Look for an edit overlapping the region start >+ >+ // Look for an edit overlapping the region start > while (bottom <= top) { > i = bottom + (top - bottom) /2; > edit = sortedEdits[i]; >@@ -300,7 +302,7 @@ > if (before) linesOutside++; > } > } >- >+ > // Restart the edit at the beginning of the line where the region start > edit.offset = regionStart; > edit.length -= edit.offset - editStart; >@@ -352,8 +354,8 @@ > } > } > } >- >- // Look for an edit overlapping the region end >+ >+ // Look for an edit overlapping the region end > if (overlapIndex != -1) bottom = overlapIndex; > while (bottom <= topEnd) { > i = bottom + (topEnd - bottom) /2; >@@ -823,7 +825,7 @@ > linePtr = -linePtr - 1; > } > int offset = 0; >- int beginningOfLine = getLineEnd(linePtr); >+ int beginningOfLine = getLineEnd(linePtr)+1; > if (beginningOfLine == -1) { > beginningOfLine = 0; > } >@@ -978,29 +980,86 @@ > // preserve line breaks in wrapping if specified > // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=198074 > if (this.currentAlignment != null && !this.formatter.preferences.join_wrapped_lines) { >- // insert a new line only if it has not been already done before >- // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=283476 >- if (this.lastNumberOfNewLines == 0) { >+ // Insert a new line only if it has not been already done before >+ // (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=283476) >+ // or when there's no direct member alignment >+ // (additional fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=286601) >+ if (this.lastNumberOfNewLines == 0 || this.memberAlignment == null || this.memberAlignment.location.inputOffset < this.currentAlignment.location.inputOffset) { >+ >+ // Debug >+ if (DefaultCodeFormatter.DEBUG) { >+ System.out.println("Preserve empty lines:"); //$NON-NLS-1$ >+ System.out.println(" - indentation level = "+this.indentationLevel); //$NON-NLS-1$ >+ System.out.println(" - current alignment: "); //$NON-NLS-1$ >+ System.out.print(this.currentAlignment.toString(new StringBuffer(), 1)); >+ if (this.memberAlignment != null) { >+ System.out.println(" - member alignment: "); //$NON-NLS-1$ >+ System.out.print(this.memberAlignment.toString(new StringBuffer(), 1)); >+ } >+ } >+ > // Reset indentation level to the location output > this.indentationLevel = this.currentAlignment.location.outputIndentationLevel; >- this.numberOfIndentations = this.currentAlignment.location.numberOfIndentations; >- this.formatter.lastLocalDeclarationSourceStart = this.currentAlignment.location.lastLocalDeclarationSourceStart; >- // Create new line keeping the existing indentation >+ >+ // Create new line > StringBuffer buffer = new StringBuffer(getNewLine()); >+ >+ // Look for current indentation > int currentColumn = getCurrentIndentation(this.scanner.currentPosition); >- Alignment rootAlignment = this.currentAlignment; >- while (rootAlignment.enclosing != null) { >- rootAlignment = rootAlignment.enclosing; >- } >- Location location = rootAlignment.location; >- if (currentColumn > location.inputColumn) { >- int savedIndentation = this.indentationLevel; >- this.indentationLevel += currentColumn - location.inputColumn; >- printIndentationIfNecessary(buffer); >- this.indentationLevel = savedIndentation; >- } else { >- printIndentationIfNecessary(buffer); >+ >+ // Determine whether the alignment indentation can be used or not >+ // So far, the best algorithm is to use it when >+ // 1. this is not the opening brace of a local declaration assignment >+ // 2. this is not the first opening brace >+ // or this is an array initializer alignment >+ // or this is an binary expression alignment >+ // 3. the indentation level is below the alignment break indentation >+ int currentTokenStartPosition = this.scanner.currentPosition; >+ int nextToken = -1; >+ try { >+ nextToken = this.scanner.getNextToken(); >+ } catch (InvalidInputException e) { >+ // skip >+ } >+ this.scanner.resetTo(currentTokenStartPosition, this.scannerEndPosition - 1); >+ boolean canUseAlignmentIndentation = (nextToken != TerminalTokens.TokenNameLBRACE || !this.currentAlignment.name.equals("localDeclarationAssignmentAlignment")); //$NON-NLS-1$ >+ if (canUseAlignmentIndentation && >+ (!this.formatBrace || >+ this.currentAlignment.name.equals("array_initializer") || //$NON-NLS-1$ >+ this.currentAlignment.name.equals("binaryExpressionAlignment")) && //$NON-NLS-1$ >+ this.indentationLevel < this.currentAlignment.breakIndentationLevel) { >+ this.indentationLevel = this.currentAlignment.breakIndentationLevel; > } >+ >+ // Use the current indentation if over the computed indentation >+ if (this.indentationLevel < currentColumn) { >+ this.indentationLevel = currentColumn; >+ } >+ >+ // Debug >+ if (DefaultCodeFormatter.DEBUG) { >+ System.out.println(" - format brace = "+this.formatBrace); //$NON-NLS-1$ >+ System.out.println(" - current column = "+currentColumn); //$NON-NLS-1$ >+ System.out.println(" - current position = "+this.scanner.currentPosition); //$NON-NLS-1$ >+ System.out.print(" - current line = "); //$NON-NLS-1$ >+ int linePtr = Arrays.binarySearch(this.lineEnds, this.scanner.currentPosition); >+ if (linePtr < 0) { >+ linePtr = -linePtr - 1; >+ } >+ int i = getLineEnd(linePtr)+1; >+ while (this.scanner.source[i] != '\r') { >+ System.out.print(this.scanner.source[i++]); >+ } >+ System.out.println(); >+ System.out.println(" - indentation level = "+this.indentationLevel); //$NON-NLS-1$ >+ System.out.println(); >+ } >+ >+ // Set the flag to indicate that a specific indentation is currently in used >+ this.preserveLineBreakIndentation = true; >+ >+ // Print the computed indentation in the buffer >+ printIndentationIfNecessary(buffer); > return buffer.toString(); > } > } >@@ -1325,7 +1384,7 @@ > try { > while (nextCharacterStart <= currentTokenEndPosition && (currentCharacter = this.scanner.getNextChar()) != -1) { > nextCharacterStart = this.scanner.currentPosition; >- >+ > switch(currentCharacter) { > case '\r' : > start = previousStart; >@@ -1345,7 +1404,7 @@ > this.column = 1; > this.line++; > isNewLine = false; >- >+ > StringBuffer buffer = new StringBuffer(); > if (onFirstColumn) { > // simply insert indentation if necessary >@@ -2379,7 +2438,7 @@ > break; > } > } >- >+ > // Delete leading whitespaces if any > if (previousToken != -1 && lastTokenEndPosition != commentStart && spaceEndPosition > lastTokenEndPosition) { > addDeleteEdit(lastTokenEndPosition, spaceEndPosition-1); >@@ -3810,7 +3869,12 @@ > return; > } > if (this.lastNumberOfNewLines >= 1) { >- this.column = 1; // ensure that the scribe is at the beginning of a new line >+ // ensure that the scribe is at the beginning of a new line >+ // only if no specific indentation has been previously set >+ if (!this.preserveLineBreakIndentation) { >+ this.column = 1; >+ } >+ this.preserveLineBreakIndentation = false; > return; > } > addInsertEdit(insertPosition, this.lineSeparator); >@@ -3819,22 +3883,39 @@ > this.column = 1; > this.needSpace = false; > this.pendingSpace = false; >+ this.preserveLineBreakIndentation = false; > } > > public void printNextToken(int expectedTokenType){ > printNextToken(expectedTokenType, false); > } > >- public void printNextToken(int expectedTokenType, boolean considerSpaceIfAny){ >- printComment(CodeFormatter.K_UNKNOWN); >+ public void printNextToken(int expectedTokenType, boolean considerSpaceIfAny) { >+ // Set brace flag, it's useful for the scribe while preserving line breaks >+ switch (expectedTokenType) { >+ case TerminalTokens.TokenNameRBRACE: >+ case TerminalTokens.TokenNameLBRACE: >+ this.formatBrace = true; >+ } > try { >- this.currentToken = this.scanner.getNextToken(); >- if (expectedTokenType != this.currentToken) { >- throw new AbortFormatting("unexpected token type, expecting:"+expectedTokenType+", actual:"+this.currentToken);//$NON-NLS-1$//$NON-NLS-2$ >+ printComment(CodeFormatter.K_UNKNOWN); >+ try { >+ this.currentToken = this.scanner.getNextToken(); >+ if (expectedTokenType != this.currentToken) { >+ throw new AbortFormatting("unexpected token type, expecting:"+expectedTokenType+", actual:"+this.currentToken);//$NON-NLS-1$//$NON-NLS-2$ >+ } >+ print(this.scanner.currentPosition - this.scanner.startPosition, considerSpaceIfAny); >+ } catch (InvalidInputException e) { >+ throw new AbortFormatting(e); >+ } >+ } >+ finally { >+ // Flush brace flag >+ switch (expectedTokenType) { >+ case TerminalTokens.TokenNameRBRACE: >+ case TerminalTokens.TokenNameLBRACE: >+ this.formatBrace = false; > } >- print(this.scanner.currentPosition - this.scanner.startPosition, considerSpaceIfAny); >- } catch (InvalidInputException e) { >- throw new AbortFormatting(e); > } > } > >Index: formatter/org/eclipse/jdt/internal/formatter/align/Alignment.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/align/Alignment.java,v >retrieving revision 1.35 >diff -u -r1.35 Alignment.java >--- formatter/org/eclipse/jdt/internal/formatter/align/Alignment.java 21 Aug 2009 08:28:20 -0000 1.35 >+++ formatter/org/eclipse/jdt/internal/formatter/align/Alignment.java 25 Oct 2009 14:13:08 -0000 >@@ -379,18 +379,26 @@ > > public String toString() { > StringBuffer buffer = new StringBuffer(10); >- String className = getClass().getName(); >- className = className.substring(className.lastIndexOf('.')+1); >+ return toString(buffer, -1); >+ } >+ >+ public String toString(StringBuffer buffer, int level) { >+ >+ // Compute the indentation at the given level >+ StringBuffer indentation = new StringBuffer(); >+ for (int i=0; i<level; i++) { >+ indentation.append('\t'); >+ } >+ >+ // First line is for class and name >+ buffer.append(indentation); > buffer >- .append(className) >- .append(":<name: ") //$NON-NLS-1$ >+ .append("<name: ") //$NON-NLS-1$ > .append(this.name) >- .append(">"); //$NON-NLS-1$ >- int indentLength = className.length()+1; >- buffer.append('\n'); >- for (int i=0; i<indentLength; i++) { >- buffer.append(' '); >- } >+ .append(">\n"); //$NON-NLS-1$ >+ >+ // Line for depth and break indentation >+ buffer.append(indentation); > buffer > .append("<depth=") //$NON-NLS-1$ > .append(depth()) >@@ -398,18 +406,23 @@ > .append(this.breakIndentationLevel) > .append("><shiftBreakIndent=") //$NON-NLS-1$ > .append(this.shiftBreakIndentationLevel) >- .append('>'); >- if (this.enclosing != null) { >- buffer >- .append("<enclosingName: ") //$NON-NLS-1$ >- .append(this.enclosing.name) >- .append('>'); >- } >- buffer.append('\n'); >+ .append(">\n"); //$NON-NLS-1$ > >+ // Line to display the location >+ buffer.append(indentation); >+ buffer >+ .append("<location=") //$NON-NLS-1$ >+ .append(this.location.toString()) >+ .append(">\n"); //$NON-NLS-1$ >+ >+ // Lines for fragments >+ buffer >+ .append(indentation) >+ .append("<fragments:\n"); //$NON-NLS-1$ > for (int i = 0; i < this.fragmentCount; i++){ > buffer >- .append(" - fragment ") //$NON-NLS-1$ >+ .append(indentation) >+ .append(" - ") //$NON-NLS-1$ > .append(i) > .append(": ") //$NON-NLS-1$ > .append("<break: ") //$NON-NLS-1$ >@@ -419,7 +432,22 @@ > .append(this.fragmentIndentations[i]) > .append(">\n"); //$NON-NLS-1$ > } >- buffer.append('\n'); >+ buffer >+ .append(indentation) >+ .append(">\n"); //$NON-NLS-1$ >+ >+ // Display enclosing >+ if (this.enclosing != null && level >= 0) { >+ buffer >+ .append(indentation) >+ .append("<enclosing assignement:\n"); //$NON-NLS-1$ >+ this.enclosing.toString(buffer, level+1); >+ buffer >+ .append(indentation) >+ .append(">\n"); //$NON-NLS-1$ >+ } >+ >+ // Return the result > return buffer.toString(); > } > >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java,v >retrieving revision 1.3 >diff -u -r1.3 FormatterBugsTests.java >--- src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java 24 Oct 2009 21:26:26 -0000 1.3 >+++ src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java 25 Oct 2009 14:13:11 -0000 >@@ -27,6 +27,30 @@ > super(name); > } > >+/* (non-Javadoc) >+ * @see org.eclipse.jdt.core.tests.formatter.FormatterRegressionTests#setUp() >+ */ >+private void setUpBracesPreferences(String braces) { >+ if (braces != null) { >+ assertTrue("Invalid value for braces preferences: "+braces, >+ braces.equals(DefaultCodeFormatterConstants.END_OF_LINE) || >+ braces.equals(DefaultCodeFormatterConstants.NEXT_LINE) || >+ braces.equals(DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP) || >+ braces.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)); >+ this.formatterPrefs.brace_position_for_annotation_type_declaration = braces; >+ this.formatterPrefs.brace_position_for_anonymous_type_declaration = braces; >+ this.formatterPrefs.brace_position_for_array_initializer = braces; >+ this.formatterPrefs.brace_position_for_block = braces; >+ this.formatterPrefs.brace_position_for_block_in_case = braces; >+ this.formatterPrefs.brace_position_for_constructor_declaration = braces; >+ this.formatterPrefs.brace_position_for_enum_constant = braces; >+ this.formatterPrefs.brace_position_for_enum_declaration = braces; >+ this.formatterPrefs.brace_position_for_method_declaration = braces; >+ this.formatterPrefs.brace_position_for_switch = braces; >+ this.formatterPrefs.brace_position_for_type_declaration = braces; >+ } >+} >+ > /** > * Create project and set the jar placeholder. > */ >@@ -58,8 +82,8 @@ > "\n" + > " void foo() {\n" + > " String x = \"select x \"\n" + >- " + \"from y \"\n" + >- " + \"where z=a\";\n" + >+ " + \"from y \"\n" + >+ " + \"where z=a\";\n" + > " }\n" + > "}\n" > ); >@@ -81,8 +105,8 @@ > "\n" + > " void foo() {\n" + > " String x = \"select x \"\n" + >- " + \"from y \"\n" + >- " + \"where z=a\";\n" + >+ " + \"from y \"\n" + >+ " + \"where z=a\";\n" + > " }\n" + > "}\n" > ); >@@ -110,7 +134,7 @@ > " // we need x\n" + > " // we need a select\n" + > " return \"select x \"\n" + >- " + \"from X\";\n" + >+ " + \"from X\";\n" + > " }\n" + > " return null;\n" + > " }\n" + >@@ -140,7 +164,7 @@ > " // we need x\n" + > " // we need a select\n" + > " return \"select x \"\n" + >- " + \"from X\";\n" + >+ " + \"from X\";\n" + > " }\n" + > " return null;\n" + > " }\n" + >@@ -168,11 +192,11 @@ > "\n" + > " public String toString() {\n" + > " return \"YAD01: \"\n" + >- " + \" nommbr=\'\" + getName() + \"\'\"\n" + >- " + \" nomgrp=\'\" + getService().getArgtbl() + \"\'\"\n" + >- " + \" typmbr=\'\" + getMemberType().getArgument() + \"\'\"\n" + >- " + \" srcpat=\'\" + getPhysicalPath() + \"\'\"\n" + >- " + \" nommdl=\'\" + getModel() + \"\'\";\n" + >+ " + \" nommbr=\'\" + getName() + \"\'\"\n" + >+ " + \" nomgrp=\'\" + getService().getArgtbl() + \"\'\"\n" + >+ " + \" typmbr=\'\" + getMemberType().getArgument() + \"\'\"\n" + >+ " + \" srcpat=\'\" + getPhysicalPath() + \"\'\"\n" + >+ " + \" nommdl=\'\" + getModel() + \"\'\";\n" + > " }\n" + > "}\n" > ); >@@ -185,11 +209,11 @@ > "\n" + > "public String toString() {\n" + > " return \"YAD01: \"\n" + >- " + \" nommbr=\'\"+getName()+\"\'\"\n" + >- " + \" nomgrp=\'\"+getService().getArgtbl()+\"\'\"\n" + >- " + \" typmbr=\'\"+getMemberType().getArgument()+\"\'\"\n" + >- " + \" srcpat=\'\"+getPhysicalPath()+\"\'\"\n" + >- " + \" nommdl=\'\"+getModel()+\"\'\"\n" + >+ " + \" nommbr=\'\"+getName()+\"\'\"\n" + >+ " + \" nomgrp=\'\"+getService().getArgtbl()+\"\'\"\n" + >+ " + \" typmbr=\'\"+getMemberType().getArgument()+\"\'\"\n" + >+ " + \" srcpat=\'\"+getPhysicalPath()+\"\'\"\n" + >+ " + \" nommdl=\'\"+getModel()+\"\'\"\n" + > " ;\n" + > "}\n" + > "}\n"; >@@ -198,11 +222,11 @@ > "\n" + > " public String toString() {\n" + > " return \"YAD01: \"\n" + >- " + \" nommbr=\'\" + getName() + \"\'\"\n" + >- " + \" nomgrp=\'\" + getService().getArgtbl() + \"\'\"\n" + >- " + \" typmbr=\'\" + getMemberType().getArgument() + \"\'\"\n" + >- " + \" srcpat=\'\" + getPhysicalPath() + \"\'\"\n" + >- " + \" nommdl=\'\" + getModel() + \"\'\";\n" + >+ " + \" nommbr=\'\" + getName() + \"\'\"\n" + >+ " + \" nomgrp=\'\" + getService().getArgtbl() + \"\'\"\n" + >+ " + \" typmbr=\'\" + getMemberType().getArgument() + \"\'\"\n" + >+ " + \" srcpat=\'\" + getPhysicalPath() + \"\'\"\n" + >+ " + \" nommdl=\'\" + getModel() + \"\'\";\n" + > " }\n" + > "}\n" > ); >@@ -247,10 +271,10 @@ > "\n" + > " void foo() {\n" + > " String sQuery =\n" + >- " \"select * \" +\n" + >- " \"from person p, address a \" +\n" + >- " \"where p.person_id = a.person_id \" +\n" + >- " \"and p.person_id = ?\";\n" + >+ " \"select * \" +\n" + >+ " \"from person p, address a \" +\n" + >+ " \"where p.person_id = a.person_id \" +\n" + >+ " \"and p.person_id = ?\";\n" + > " }\n" + > "}\n" > ); >@@ -276,8 +300,8 @@ > " void foo() {\n" + > " int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0;\n" + > " if ((a == b && b == c) &&\n" + >- " (d == e) &&\n" + >- " (f == g && h == i)) {\n" + >+ " (d == e) &&\n" + >+ " (f == g && h == i)) {\n" + > " }\n" + > " }\n" + > "}\n" >@@ -514,25 +538,445 @@ > public void testBug286601c() { > this.formatterPrefs.join_wrapped_lines = false; > this.formatterPrefs.brace_position_for_anonymous_type_declaration= DefaultCodeFormatterConstants.NEXT_LINE; >- String source = >+ String source = >+ "public class Test\n" + >+ "{\n" + >+ " public void aMethod()\n" + >+ " {\n" + >+ " Object anObject = new Object()\n" + >+ " {\n" + >+ " boolean aVariable;\n" + >+ " void foo()\n" + >+ " {\n" + >+ " }\n" + >+ " };\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class Test {\n" + >+ " public void aMethod() {\n" + >+ " Object anObject = new Object()\n" + >+ " {\n" + >+ " boolean aVariable;\n" + >+ "\n" + >+ " void foo()\n" + >+ " {\n" + >+ " }\n" + >+ " };\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug286601d() { >+ this.formatterPrefs.join_wrapped_lines = false; >+ this.formatterPrefs.brace_position_for_anonymous_type_declaration= DefaultCodeFormatterConstants.NEXT_LINE; >+ String source = >+ "public class Test\n" + >+ "{\n" + >+ " public void aMethod()\n" + >+ " {\n" + >+ " Object anObject = new Object() /* comment */\n" + >+ " {\n" + >+ " boolean aVariable;\n" + >+ " void foo() /* comment */ \n" + >+ " {\n" + >+ " }\n" + >+ " };\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class Test {\n" + >+ " public void aMethod() {\n" + >+ " Object anObject = new Object() /* comment */\n" + >+ " {\n" + >+ " boolean aVariable;\n" + >+ "\n" + >+ " void foo() /* comment */\n" + >+ " {\n" + >+ " }\n" + >+ " };\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug286601e() { >+ this.formatterPrefs.join_wrapped_lines = false; >+ setUpBracesPreferences(DefaultCodeFormatterConstants.NEXT_LINE); >+ String source = >+ "public class Test\n" + >+ "{\n" + >+ " public void build(String href) {\n" + >+ " // set the href on the related topic\n" + >+ " if (href == null)\n" + >+ " setHref(\"\"); //$NON-NLS-1$\n" + >+ " else {\n" + >+ " if (!href.equals(\"\") // no empty link //$NON-NLS-1$\n" + >+ " && !href.startsWith(\"/\") // no help url //$NON-NLS-1$\n" + >+ " && href.indexOf(\':\') == -1) // no other protocols\n" + >+ " {\n" + >+ " setHref(\"/test/\" + href); //$NON-NLS-1$ //$NON-NLS-2$\n" + >+ " }\n" + >+ " }\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, > "public class Test\n" + > "{\n" + >- " public void aMethod()\n" + >- " {\n" + >- " Object anObject = new Object()\n" + >- " {\n" + >- " boolean aVariable;\n" + >+ " public void build(String href)\n" + >+ " {\n" + >+ " // set the href on the related topic\n" + >+ " if (href == null)\n" + >+ " setHref(\"\"); //$NON-NLS-1$\n" + >+ " else\n" + >+ " {\n" + >+ " if (!href.equals(\"\") // no empty link //$NON-NLS-1$\n" + >+ " && !href.startsWith(\"/\") // no help url //$NON-NLS-1$\n" + >+ " && href.indexOf(\':\') == -1) // no other protocols\n" + >+ " {\n" + >+ " setHref(\"/test/\" + href); //$NON-NLS-1$ //$NON-NLS-2$\n" + >+ " }\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug286601f() { >+ this.formatterPrefs.join_wrapped_lines = false; >+ setUpBracesPreferences(DefaultCodeFormatterConstants.NEXT_LINE); >+ String source = >+ "public class Test\n" + >+ "{\n" + >+ " \n" + >+ " private AntModel getAntModel(final File buildFile) {\n" + >+ " AntModel model= new AntModel(XMLCore.getDefault(), doc, null, new LocationProvider(null) {\n" + >+ " /* (non-Javadoc)\n" + >+ " * @see org.eclipse.ant.internal.ui.editor.outline.ILocationProvider#getLocation()\n" + >+ " */\n" + >+ " public IPath getLocation() {\n" + >+ " return new Path(buildFile.getAbsolutePath());\n" + >+ " }\n" + >+ " });\n" + >+ " model.reconcile(null);\n" + >+ " return model;\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class Test\n" + >+ "{\n" + >+ "\n" + >+ " private AntModel getAntModel(final File buildFile)\n" + >+ " {\n" + >+ " AntModel model = new AntModel(XMLCore.getDefault(), doc, null,\n" + >+ " new LocationProvider(null)\n" + >+ " {\n" + >+ " /*\n" + >+ " * (non-Javadoc)\n" + >+ " * \n" + >+ " * @see\n" + >+ " * org.eclipse.ant.internal.ui.editor.outline.ILocationProvider\n" + >+ " * #getLocation()\n" + >+ " */\n" + >+ " public IPath getLocation()\n" + >+ " {\n" + >+ " return new Path(buildFile.getAbsolutePath());\n" + >+ " }\n" + >+ " });\n" + >+ " model.reconcile(null);\n" + >+ " return model;\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug286601g() { >+ this.formatterPrefs.join_wrapped_lines = false; >+ String source = >+ "package massive;\n" + >+ "\n" + >+ "public class X05b\n" + >+ "{\n" + >+ "\n" + >+ " public void foo() throws NullPointerException {\n" + >+ "\n" + >+ " Object body = new Object() {\n" + >+ " public void run(StringBuffer monitor) throws IllegalArgumentException {\n" + >+ " IResourceVisitor visitor = new IResourceVisitor() {\n" + >+ " public boolean visit(String resource) throws IllegalArgumentException {\n" + >+ " return true;\n" + >+ " }\n" + >+ " };\n" + >+ " }\n" + > " };\n" + > " }\n" + >+ "\n" + >+ "}\n" + >+ "interface IResourceVisitor {\n" + > "}\n"; > formatSource(source, >- "public class Test {\n" + >- " public void aMethod() {\n" + >- " Object anObject = new Object()\n" + >+ "package massive;\n" + >+ "\n" + >+ "public class X05b {\n" + >+ "\n" + >+ " public void foo() throws NullPointerException {\n" + >+ "\n" + >+ " Object body = new Object() {\n" + >+ " public void run(StringBuffer monitor)\n" + >+ " throws IllegalArgumentException {\n" + >+ " IResourceVisitor visitor = new IResourceVisitor() {\n" + >+ " public boolean visit(String resource)\n" + >+ " throws IllegalArgumentException {\n" + >+ " return true;\n" + >+ " }\n" + >+ " };\n" + >+ " }\n" + >+ " };\n" + >+ " }\n" + >+ "\n" + >+ "}\n" + >+ "\n" + >+ "interface IResourceVisitor {\n" + >+ "}\n" >+ ); >+} >+public void testBug286601h() { >+ this.formatterPrefs.join_wrapped_lines = false; >+ setUpBracesPreferences(DefaultCodeFormatterConstants.NEXT_LINE); >+ String source = >+ "package massive;\n" + >+ "\n" + >+ "public class X05b\n" + >+ "{\n" + >+ "\n" + >+ " public void foo() throws NullPointerException {\n" + >+ "\n" + >+ " Object body = new Object() {\n" + >+ " public void run(StringBuffer monitor) throws IllegalArgumentException {\n" + >+ " IResourceVisitor visitor = new IResourceVisitor() {\n" + >+ " public boolean visit(String resource) throws IllegalArgumentException {\n" + >+ " return true;\n" + >+ " }\n" + >+ " };\n" + >+ " }\n" + >+ " };\n" + >+ " }\n" + >+ "\n" + >+ "}\n" + >+ "interface IResourceVisitor {\n" + >+ "}\n"; >+ formatSource(source, >+ "package massive;\n" + >+ "\n" + >+ "public class X05b\n" + >+ "{\n" + >+ "\n" + >+ " public void foo() throws NullPointerException\n" + >+ " {\n" + >+ "\n" + >+ " Object body = new Object()\n" + > " {\n" + >- " boolean aVariable;\n" + >+ " public void run(StringBuffer monitor)\n" + >+ " throws IllegalArgumentException\n" + >+ " {\n" + >+ " IResourceVisitor visitor = new IResourceVisitor()\n" + >+ " {\n" + >+ " public boolean visit(String resource)\n" + >+ " throws IllegalArgumentException\n" + >+ " {\n" + >+ " return true;\n" + >+ " }\n" + >+ " };\n" + >+ " }\n" + > " };\n" + > " }\n" + >+ "\n" + >+ "}\n" + >+ "\n" + >+ "interface IResourceVisitor\n" + >+ "{\n" + >+ "}\n" >+ ); >+} >+public void testBug286601i1() { >+ this.formatterPrefs.join_wrapped_lines = false; >+ this.formatterPrefs.alignment_for_expressions_in_array_initializer = DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE; >+ setUpBracesPreferences(DefaultCodeFormatterConstants.NEXT_LINE); >+ String source = >+ "package massive;\n" + >+ "\n" + >+ "public class X06a {\n" + >+ "\n" + >+ " \n" + >+ " // Table to merge access modes for condition statements (e.g branch[x] || branch[y]). \n" + >+ " private static final String[][] ACCESS_MODE_CONDITIONAL_TABLE= {\n" + >+ " /* Comment 1 */\n" + >+ " /* Comment 2 */ { \"1234567890123456789012345678901234567890\", \"1234567890123456789012345678901234567890\" },\n" + >+ " /* Comment 3 */ { \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\", \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\" },\n" + >+ " };\n" + >+ "\n" + >+ "}\n"; >+ formatSource(source, >+ "package massive;\n" + >+ "\n" + >+ "public class X06a\n" + >+ "{\n" + >+ "\n" + >+ " // Table to merge access modes for condition statements (e.g branch[x] ||\n" + >+ " // branch[y]).\n" + >+ " private static final String[][] ACCESS_MODE_CONDITIONAL_TABLE =\n" + >+ " {\n" + >+ " /* Comment 1 */\n" + >+ " /* Comment 2 */{ \"1234567890123456789012345678901234567890\", \"1234567890123456789012345678901234567890\" },\n" + >+ " /* Comment 3 */{ \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\", \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\" },\n" + >+ " };\n" + >+ "\n" + >+ "}\n" >+ ); >+} >+public void testBug286601i2() { >+ this.formatterPrefs.join_wrapped_lines = false; >+ this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE; >+ this.formatterPrefs.alignment_for_expressions_in_array_initializer = DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE; >+ setUpBracesPreferences(DefaultCodeFormatterConstants.NEXT_LINE); >+ String source = >+ "package massive;\n" + >+ "\n" + >+ "public class X06a {\n" + >+ "\n" + >+ " \n" + >+ " // Table to merge access modes for condition statements (e.g branch[x] || branch[y]). \n" + >+ " private static final String[][] ACCESS_MODE_CONDITIONAL_TABLE= {\n" + >+ " /* Comment 1 */\n" + >+ " /* Comment 2 */ { \"1234567890123456789012345678901234567890\", \"1234567890123456789012345678901234567890\" },\n" + >+ " /* Comment 3 */ { \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\", \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\" },\n" + >+ " };\n" + >+ "\n" + >+ "}\n"; >+ formatSource(source, >+ "package massive;\n" + >+ "\n" + >+ "public class X06a\n" + >+ "{\n" + >+ "\n" + >+ " // Table to merge access modes for condition statements (e.g branch[x] ||\n" + >+ " // branch[y]).\n" + >+ " private static final String[][] ACCESS_MODE_CONDITIONAL_TABLE =\n" + >+ " {\n" + >+ " /* Comment 1 */\n" + >+ " /* Comment 2 */{ \"1234567890123456789012345678901234567890\", \"1234567890123456789012345678901234567890\" },\n" + >+ " /* Comment 3 */{ \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\", \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\" },\n" + >+ " };\n" + >+ "\n" + >+ "}\n" >+ ); >+} >+public void testBug286601j1() { >+ this.formatterPrefs.join_wrapped_lines = false; >+ this.formatterPrefs.alignment_for_expressions_in_array_initializer = DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE; >+ setUpBracesPreferences(DefaultCodeFormatterConstants.NEXT_LINE); >+ String source = >+ "package massive;\n" + >+ "\n" + >+ "public class X06b {\n" + >+ "\n" + >+ " \n" + >+ " // Table to merge access modes for condition statements (e.g branch[x] || branch[y]). \n" + >+ " private static final String[][] ACCESS_MODE_CONDITIONAL_TABLE= {\n" + >+ " { \"1234567890123456789012345678901234567890\", \"1234567890123456789012345678901234567890\" },\n" + >+ " { \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\", \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\" },\n" + >+ " };\n" + >+ "\n" + >+ "}\n"; >+ formatSource(source, >+ "package massive;\n" + >+ "\n" + >+ "public class X06b\n" + >+ "{\n" + >+ "\n" + >+ " // Table to merge access modes for condition statements (e.g branch[x] ||\n" + >+ " // branch[y]).\n" + >+ " private static final String[][] ACCESS_MODE_CONDITIONAL_TABLE =\n" + >+ " {\n" + >+ " { \"1234567890123456789012345678901234567890\", \"1234567890123456789012345678901234567890\" },\n" + >+ " { \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\", \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\" },\n" + >+ " };\n" + >+ "\n" + >+ "}\n" >+ ); >+} >+public void testBug286601j2() { >+ this.formatterPrefs.join_wrapped_lines = false; >+ this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE; >+ this.formatterPrefs.alignment_for_expressions_in_array_initializer = DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE; >+ setUpBracesPreferences(DefaultCodeFormatterConstants.NEXT_LINE); >+ String source = >+ "package massive;\n" + >+ "\n" + >+ "public class X06b {\n" + >+ "\n" + >+ " \n" + >+ " // Table to merge access modes for condition statements (e.g branch[x] || branch[y]). \n" + >+ " private static final String[][] ACCESS_MODE_CONDITIONAL_TABLE= {\n" + >+ " { \"1234567890123456789012345678901234567890\", \"1234567890123456789012345678901234567890\" },\n" + >+ " { \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\", \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\" },\n" + >+ " };\n" + >+ "\n" + >+ "}\n"; >+ formatSource(source, >+ "package massive;\n" + >+ "\n" + >+ "public class X06b\n" + >+ "{\n" + >+ "\n" + >+ " // Table to merge access modes for condition statements (e.g branch[x] ||\n" + >+ " // branch[y]).\n" + >+ " private static final String[][] ACCESS_MODE_CONDITIONAL_TABLE =\n" + >+ " {\n" + >+ " { \"1234567890123456789012345678901234567890\", \"1234567890123456789012345678901234567890\" },\n" + >+ " { \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\", \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\" },\n" + >+ " };\n" + >+ "\n" + >+ "}\n" >+ ); >+} >+public void testBug286601k() { >+ this.formatterPrefs.join_wrapped_lines = false; >+ this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE; >+ this.formatterPrefs.alignment_for_expressions_in_array_initializer = DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE; >+ setUpBracesPreferences(DefaultCodeFormatterConstants.NEXT_LINE); >+ String source = >+ "package massive;\n" + >+ "\n" + >+ "public class X07 {\n" + >+ " private MinimizedFileSystemElement selectFiles(final Object rootFileSystemObject, final IImportStructureProvider structureProvider) {\n" + >+ "\n" + >+ " BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {\n" + >+ " public void run() {\n" + >+ " //Create the root element from the supplied file system object\n" + >+ " }\n" + >+ " });\n" + >+ "\n" + >+ " return null;\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "package massive;\n" + >+ "\n" + >+ "public class X07\n" + >+ "{\n" + >+ " private MinimizedFileSystemElement selectFiles(\n" + >+ " final Object rootFileSystemObject,\n" + >+ " final IImportStructureProvider structureProvider)\n" + >+ " {\n" + >+ "\n" + >+ " BusyIndicator.showWhile(getShell().getDisplay(), new Runnable()\n" + >+ " {\n" + >+ " public void run()\n" + >+ " {\n" + >+ " // Create the root element from the supplied file system object\n" + >+ " }\n" + >+ " });\n" + >+ "\n" + >+ " return null;\n" + >+ " }\n" + > "}\n" > ); > } >@@ -560,7 +1004,7 @@ > " StringBuilder builder = new StringBuilder();\n" + > " builder.append(\"abc\").append(\"def\").append(\"ghi\").append(\"jkl\").append(\n" + > " \"mno\")\n" + >- " .append(\"pqr\").append(\"stu\").append(\"vwx\").append(\"yz\");\n" + >+ " .append(\"pqr\").append(\"stu\").append(\"vwx\").append(\"yz\");\n" + > " }\n" + > "}\n" > ); >@@ -577,7 +1021,17 @@ > " .append(\"pqr\").append(\"stu\").append(\"vwx\").append(\"yz\");\n" + > " }\n" + > "}\n"; >- formatSource(source); >+ formatSource(source, >+ "public class Test {\n" + >+ "\n" + >+ " void foo() {\n" + >+ " StringBuilder builder = new StringBuilder();\n" + >+ " builder.append(\"abc\").append(\"def\")\n" + >+ " .append(\"ghi\").append(\"jkl\").append(\"mno\")\n" + >+ " .append(\"pqr\").append(\"stu\").append(\"vwx\").append(\"yz\");\n" + >+ " }\n" + >+ "}\n" >+ ); > } > public void testBug286668c() throws JavaModelException { > this.formatterPrefs.join_wrapped_lines = false; >@@ -592,7 +1046,18 @@ > " .append(\"yz\");\n" + > " }\n" + > "}\n"; >- formatSource(source); >+ formatSource(source, >+ "public class Test {\n" + >+ "\n" + >+ " void foo() {\n" + >+ " StringBuilder builder = new StringBuilder();\n" + >+ " builder.append(\"abc\").append(\"def\")\n" + >+ " .append(\"ghi\").append(\"jkl\").append(\"mno\")\n" + >+ " .append(\"pqr\").append(\"stu\").append(\"vwx\")\n" + >+ " .append(\"yz\");\n" + >+ " }\n" + >+ "}\n" >+ ); > } > public void testBug286668_40w() throws JavaModelException { > this.formatterPrefs.join_wrapped_lines = false; >@@ -615,8 +1080,9 @@ > " \"def\").append(\"ghi\")\n" + > " .append(\"jkl\").append(\n" + > " \"mno\")\n" + >- " .append(\"pqr\").append(\"stu\")\n" + >- " .append(\"vwx\").append(\n" + >+ " .append(\"pqr\").append(\n" + >+ " \"stu\").append(\n" + >+ " \"vwx\").append(\n" + > " \"yz\");\n" + > " }\n" + > "}\n" >@@ -642,10 +1108,12 @@ > " StringBuilder builder = new StringBuilder();\n" + > " builder.append(\"abc\").append(\n" + > " \"def\")\n" + >- " .append(\"ghi\").append(\"jkl\")\n" + >- " .append(\"mno\")\n" + >- " .append(\"pqr\").append(\"stu\")\n" + >- " .append(\"vwx\").append(\n" + >+ " .append(\"ghi\").append(\n" + >+ " \"jkl\").append(\n" + >+ " \"mno\")\n" + >+ " .append(\"pqr\").append(\n" + >+ " \"stu\").append(\n" + >+ " \"vwx\").append(\n" + > " \"yz\");\n" + > " }\n" + > "}\n" >@@ -672,11 +1140,13 @@ > " StringBuilder builder = new StringBuilder();\n" + > " builder.append(\"abc\").append(\n" + > " \"def\")\n" + >- " .append(\"ghi\").append(\"jkl\")\n" + >- " .append(\"mno\")\n" + >- " .append(\"pqr\").append(\"stu\")\n" + >- " .append(\"vwx\")\n" + >- " .append(\"yz\");\n" + >+ " .append(\"ghi\").append(\n" + >+ " \"jkl\").append(\n" + >+ " \"mno\")\n" + >+ " .append(\"pqr\").append(\n" + >+ " \"stu\").append(\n" + >+ " \"vwx\")\n" + >+ " .append(\"yz\");\n" + > " }\n" + > "}\n" > ); >@@ -700,8 +1170,8 @@ > " StringBuilder builder = new StringBuilder();\n" + > " builder.append(\"abc\").append(\"def\").append(\"ghi\")\n" + > " .append(\"jkl\").append(\"mno\")\n" + >- " .append(\"pqr\").append(\"stu\").append(\"vwx\").append(\n" + >- " \"yz\");\n" + >+ " .append(\"pqr\").append(\"stu\").append(\"vwx\")\n" + >+ " .append(\"yz\");\n" + > " }\n" + > "}\n" > ); >@@ -725,9 +1195,9 @@ > " void foo() {\n" + > " StringBuilder builder = new StringBuilder();\n" + > " builder.append(\"abc\").append(\"def\")\n" + >- " .append(\"ghi\").append(\"jkl\").append(\"mno\")\n" + >- " .append(\"pqr\").append(\"stu\").append(\"vwx\").append(\n" + >- " \"yz\");\n" + >+ " .append(\"ghi\").append(\"jkl\").append(\"mno\")\n" + >+ " .append(\"pqr\").append(\"stu\").append(\"vwx\")\n" + >+ " .append(\"yz\");\n" + > " }\n" + > "}\n" > ); >@@ -741,9 +1211,9 @@ > " void foo() {\n" + > " StringBuilder builder = new StringBuilder();\n" + > " builder.append(\"abc\").append(\"def\")\n" + >- " .append(\"ghi\").append(\"jkl\").append(\"mno\")\n" + >- " .append(\"pqr\").append(\"stu\").append(\"vwx\")\n" + >- " .append(\"yz\");\n" + >+ " .append(\"ghi\").append(\"jkl\").append(\"mno\")\n" + >+ " .append(\"pqr\").append(\"stu\").append(\"vwx\")\n" + >+ " .append(\"yz\");\n" + > " }\n" + > "}\n"; > formatSource(source);
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 286601
:
144516
|
144650
|
149093
|
149117
| 150464