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 165868 Details for
Bug 59891
[formatter] improve lines wrapping in nested method calls
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
v18.txt (text/plain), 66.89 KB, created by
Frederic Fusier
on 2010-04-22 21:59:33 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2010-04-22 21:59:33 EDT
Size:
66.89 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.231 >diff -u -r1.231 CodeFormatterVisitor.java >--- formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java 20 Apr 2010 11:50:12 -0000 1.231 >+++ formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java 23 Apr 2010 00:21:56 -0000 >@@ -422,7 +422,12 @@ > > if ((builder.realFragmentsSize() > 1 || fragmentsSize > 4) && numberOfParens == 0) { > this.scribe.printComment(); >- Alignment binaryExpressionAlignment = this.scribe.createAlignment("binaryExpressionAlignment", this.preferences.alignment_for_binary_expression, Alignment.R_OUTERMOST, fragmentsSize, this.scribe.scanner.currentPosition); //$NON-NLS-1$ >+ Alignment binaryExpressionAlignment = this.scribe.createAlignment( >+ Alignment.BINARY_EXPRESSION, >+ this.preferences.alignment_for_binary_expression, >+ Alignment.R_OUTERMOST, >+ fragmentsSize, >+ this.scribe.scanner.currentPosition); > this.scribe.enterAlignment(binaryExpressionAlignment); > boolean ok = false; > ASTNode[] fragments = builder.fragments(); >@@ -590,7 +595,12 @@ > if (this.preferences.insert_space_after_assignment_operator) { > this.scribe.space(); > } >- Alignment assignmentAlignment = this.scribe.createAlignment("fieldDeclarationAssignmentAlignment", this.preferences.alignment_for_assignment, Alignment.R_INNERMOST, 1, this.scribe.scanner.currentPosition); //$NON-NLS-1$ >+ Alignment assignmentAlignment = this.scribe.createAlignment( >+ Alignment.FIELD_DECLARATION_ASSIGNMENT, >+ this.preferences.alignment_for_assignment, >+ Alignment.R_INNERMOST, >+ 1, >+ this.scribe.scanner.currentPosition); > this.scribe.enterAlignment(assignmentAlignment); > boolean ok = false; > do { >@@ -672,7 +682,7 @@ > final int multipleFieldDeclarationsLength = multiFieldDeclaration.declarations.length; > > Alignment multiFieldDeclarationsAlignment =this.scribe.createAlignment( >- "multiple_field",//$NON-NLS-1$ >+ Alignment.MULTIPLE_FIELD, > this.preferences.alignment_for_multiple_fields, > multipleFieldDeclarationsLength - 1, > this.scribe.scanner.currentPosition); >@@ -956,7 +966,7 @@ > final TypeReference superclass = typeDeclaration.superclass; > if (superclass != null) { > Alignment superclassAlignment =this.scribe.createAlignment( >- "superclass", //$NON-NLS-1$ >+ Alignment.SUPER_CLASS, > this.preferences.alignment_for_superclass_in_type_declaration, > 2, > this.scribe.scanner.currentPosition); >@@ -994,7 +1004,7 @@ > } > int superInterfaceLength = superInterfaces.length; > Alignment interfaceAlignment =this.scribe.createAlignment( >- "superInterfaces",//$NON-NLS-1$ >+ Alignment.SUPER_INTERFACES, > alignment_for_superinterfaces, > superInterfaceLength+1, // implements token is first fragment > this.scribe.scanner.currentPosition); >@@ -1087,7 +1097,7 @@ > hasConstants = enumConstantsLength != 0; > if (enumConstantsLength > 1) { > Alignment enumConstantsAlignment = this.scribe.createAlignment( >- "enumConstants",//$NON-NLS-1$ >+ Alignment.ENUM_CONSTANTS, > this.preferences.alignment_for_enum_constants, > enumConstantsLength, > this.scribe.scanner.currentPosition, >@@ -1318,7 +1328,7 @@ > } > int argumentLength = arguments.length; > Alignment argumentsAlignment = this.scribe.createAlignment( >- "messageArguments", //$NON-NLS-1$ >+ Alignment.MESSAGE_ARGUMENTS, > this.preferences.alignment_for_arguments_in_method_invocation, > Alignment.R_OUTERMOST, > argumentLength, >@@ -1353,17 +1363,18 @@ > } > startingPositionInCascade = 2; > } >+ int tieBreakRule = size-startingPositionInCascade > 2 ? Alignment.R_OUTERMOST : Alignment.R_INNERMOST; > Alignment cascadingMessageSendAlignment = > this.scribe.createAlignment( >- "cascadingMessageSendAlignment", //$NON-NLS-1$ >+ Alignment.CASCADING_MESSAGE_SEND, > this.preferences.alignment_for_selector_in_method_invocation, >- Alignment.R_INNERMOST, >+ tieBreakRule, > size, > this.scribe.scanner.currentPosition); > this.scribe.enterAlignment(cascadingMessageSendAlignment); > boolean ok = false; >- boolean setStartingColumn = startingPositionInCascade == 1; >- switch (this.preferences.alignment_for_arguments_in_method_invocation) { >+ boolean setStartingColumn = true; >+ switch (this.preferences.alignment_for_arguments_in_method_invocation & Alignment.SPLIT_MASK) { > case Alignment.M_COMPACT_FIRST_BREAK_SPLIT: > case Alignment.M_NEXT_SHIFTED_SPLIT: > case Alignment.M_ONE_PER_LINE_SPLIT: >@@ -1413,15 +1424,22 @@ > this.scribe.space(); > } > int argumentLength = arguments.length; >+ int alignmentMode = this.preferences.alignment_for_arguments_in_method_invocation; > Alignment argumentsAlignment = this.scribe.createAlignment( >- "messageArguments", //$NON-NLS-1$ >- this.preferences.alignment_for_arguments_in_method_invocation, >+ Alignment.MESSAGE_ARGUMENTS, >+ alignmentMode, > Alignment.R_OUTERMOST, > argumentLength, > this.scribe.scanner.currentPosition); > this.scribe.enterAlignment(argumentsAlignment); > boolean okForArguments = false; > do { >+ switch (alignmentMode & Alignment.SPLIT_MASK) { >+ case Alignment.M_COMPACT_SPLIT: >+ case Alignment.M_NEXT_PER_LINE_SPLIT: >+ argumentsAlignment.startingColumn = this.scribe.column; >+ break; >+ } > try { > for (int j = 0; j < argumentLength; j++) { > if (j > 0) { >@@ -1429,10 +1447,16 @@ > this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); > } > this.scribe.alignFragment(argumentsAlignment, j); >- if (j > 0 && this.preferences.insert_space_after_comma_in_method_invocation_arguments) { >+ if (j == 0) { >+ int fragmentIndentation = argumentsAlignment.fragmentIndentations[j]; >+ if ((argumentsAlignment.mode & Alignment.M_INDENT_ON_COLUMN) != 0 && fragmentIndentation > 0) { >+ this.scribe.indentationLevel = fragmentIndentation; >+ } >+ } else if (this.preferences.insert_space_after_comma_in_method_invocation_arguments) { > this.scribe.space(); > } > arguments[j].traverse(this, scope); >+ argumentsAlignment.startingColumn = -1; > } > okForArguments = true; > } catch (AlignmentException e) { >@@ -1468,7 +1492,11 @@ > final int FIELD = 1, METHOD = 2, TYPE = 3; > this.scribe.lastNumberOfNewLines = 1; > ASTNode[] mergedNodes = computeMergedMemberDeclarations(nodes); >- Alignment memberAlignment = this.scribe.createMemberAlignment("typeMembers", this.preferences.align_type_members_on_columns ? Alignment.M_MULTICOLUMN : Alignment.M_NO_ALIGNMENT, 4, this.scribe.scanner.currentPosition); //$NON-NLS-1$ >+ Alignment memberAlignment = this.scribe.createMemberAlignment( >+ Alignment.TYPE_MEMBERS, >+ this.preferences.align_type_members_on_columns ? Alignment.M_MULTICOLUMN : Alignment.M_NO_ALIGNMENT, >+ 4, >+ this.scribe.scanner.currentPosition); > this.scribe.enterMemberAlignment(memberAlignment); > boolean isChunkStart = false; > boolean ok = false; >@@ -1612,7 +1640,12 @@ > if (this.preferences.insert_space_after_assignment_operator) { > this.scribe.space(); > } >- Alignment assignmentAlignment = this.scribe.createAlignment("localDeclarationAssignmentAlignment", this.preferences.alignment_for_assignment, Alignment.R_OUTERMOST, 1, this.scribe.scanner.currentPosition); //$NON-NLS-1$ >+ Alignment assignmentAlignment = this.scribe.createAlignment( >+ Alignment.LOCAL_DECLARATION_ASSIGNMENT, >+ this.preferences.alignment_for_assignment, >+ Alignment.R_OUTERMOST, >+ 1, >+ this.scribe.scanner.currentPosition); > this.scribe.enterAlignment(assignmentAlignment); > boolean ok = false; > do { >@@ -1642,9 +1675,10 @@ > Alignment messageAlignment) { > > if (messageAlignment != null) { >- this.scribe.alignFragment(messageAlignment, 0); >+ if (messageAlignment.canAlign()) { >+ this.scribe.alignFragment(messageAlignment, 0); >+ } > this.scribe.printNextToken(TerminalTokens.TokenNameDOT); >- messageAlignment.startingColumn = -1; > } > TypeReference[] typeArguments = messageSend.typeArguments; > if (typeArguments != null) { >@@ -1678,14 +1712,21 @@ > } > int argumentsLength = arguments.length; > if (argumentsLength > 1) { >+ int alignmentMode = this.preferences.alignment_for_arguments_in_method_invocation; > Alignment argumentsAlignment = this.scribe.createAlignment( >- "messageArguments", //$NON-NLS-1$ >- this.preferences.alignment_for_arguments_in_method_invocation, >+ Alignment.MESSAGE_ARGUMENTS, >+ alignmentMode, > argumentsLength, > this.scribe.scanner.currentPosition); > this.scribe.enterAlignment(argumentsAlignment); > boolean ok = false; > do { >+ switch (alignmentMode & Alignment.SPLIT_MASK) { >+ case Alignment.M_COMPACT_SPLIT: >+ case Alignment.M_NEXT_PER_LINE_SPLIT: >+ argumentsAlignment.startingColumn = this.scribe.column; >+ break; >+ } > try { > for (int i = 0; i < argumentsLength; i++) { > if (i > 0) { >@@ -1696,7 +1737,18 @@ > if (i > 0 && this.preferences.insert_space_after_comma_in_method_invocation_arguments) { > this.scribe.space(); > } >+ int fragmentIndentation = 0; >+ if (i == 0) { >+ int wrappedIndex = argumentsAlignment.wrappedIndex(); >+ if (wrappedIndex >= 0) { >+ fragmentIndentation = argumentsAlignment.fragmentIndentations[wrappedIndex]; >+ if ((argumentsAlignment.mode & Alignment.M_INDENT_ON_COLUMN) != 0 && fragmentIndentation > 0) { >+ this.scribe.indentationLevel = fragmentIndentation; >+ } >+ } >+ } > arguments[i].traverse(this, scope); >+ argumentsAlignment.startingColumn = -1; > } > ok = true; > } catch (AlignmentException e) { >@@ -1705,16 +1757,7 @@ > } while (!ok); > this.scribe.exitAlignment(argumentsAlignment, true); > } else { >- for (int i = 0; i < argumentsLength; i++) { >- if (i > 0) { >- this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_method_invocation_arguments); >- this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); >- } >- if (i > 0 && this.preferences.insert_space_after_comma_in_method_invocation_arguments) { >- this.scribe.space(); >- } >- arguments[i].traverse(this, scope); >- } >+ arguments[0].traverse(this, scope); > } > this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_method_invocation); > } else { >@@ -1741,13 +1784,19 @@ > } > int argumentLength = arguments.length; > Alignment argumentsAlignment = this.scribe.createAlignment( >- "methodArguments",//$NON-NLS-1$ >+ Alignment.METHOD_ARGUMENTS, > methodDeclarationParametersAlignment, > argumentLength, > this.scribe.scanner.currentPosition); > this.scribe.enterAlignment(argumentsAlignment); > boolean ok = false; > do { >+ switch (methodDeclarationParametersAlignment & Alignment.SPLIT_MASK) { >+ case Alignment.M_COMPACT_SPLIT: >+ case Alignment.M_NEXT_PER_LINE_SPLIT: >+ argumentsAlignment.startingColumn = this.scribe.column; >+ break; >+ } > try { > for (int i = 0; i < argumentLength; i++) { > if (i > 0) { >@@ -1755,10 +1804,16 @@ > this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); > } > this.scribe.alignFragment(argumentsAlignment, i); >- if (i > 0 && spaceAfterComma) { >+ if (i == 0) { >+ int fragmentIndentation = argumentsAlignment.fragmentIndentations[0]; >+ if ((argumentsAlignment.mode & Alignment.M_INDENT_ON_COLUMN) != 0 && fragmentIndentation > 0) { >+ this.scribe.indentationLevel = fragmentIndentation; >+ } >+ } else if (spaceAfterComma) { > this.scribe.space(); > } > arguments[i].traverse(this, methodDeclaration.scope); >+ argumentsAlignment.startingColumn = -1; > } > ok = true; > } catch (AlignmentException e) { >@@ -1792,7 +1847,7 @@ > if (arguments != null) { > int argumentLength = arguments.length; > Alignment argumentsAlignment = this.scribe.createAlignment( >- "enumConstantArguments",//$NON-NLS-1$ >+ Alignment.ENUM_CONSTANTS_ARGUMENTS, > methodDeclarationParametersAlignment, > argumentLength, > this.scribe.scanner.currentPosition); >@@ -1930,7 +1985,7 @@ > if (thrownExceptions != null) { > int thrownExceptionsLength = thrownExceptions.length; > Alignment throwsAlignment = this.scribe.createAlignment( >- "throws",//$NON-NLS-1$ >+ Alignment.THROWS, > alignmentForThrowsClause, > thrownExceptionsLength, // throws is the first token > this.scribe.scanner.currentPosition); >@@ -1968,7 +2023,11 @@ > * Merged traversal of member (types, fields, methods) > */ > private void formatTypeMembers(TypeDeclaration typeDeclaration) { >- Alignment memberAlignment = this.scribe.createMemberAlignment("typeMembers", this.preferences.align_type_members_on_columns ? Alignment.M_MULTICOLUMN : Alignment.M_NO_ALIGNMENT, 3, this.scribe.scanner.currentPosition); //$NON-NLS-1$ >+ Alignment memberAlignment = this.scribe.createMemberAlignment( >+ Alignment.TYPE_MEMBERS, >+ this.preferences.align_type_members_on_columns ? Alignment.M_MULTICOLUMN : Alignment.M_NO_ALIGNMENT, >+ 3, >+ this.scribe.scanner.currentPosition); > this.scribe.enterMemberAlignment(memberAlignment); > ASTNode[] members = computeMergedMemberDeclarations(typeDeclaration); > boolean isChunkStart = false; >@@ -2329,7 +2388,7 @@ > } > int argumentLength = arguments.length; > Alignment argumentsAlignment =this.scribe.createAlignment( >- "allocation",//$NON-NLS-1$ >+ Alignment.ALLOCATION, > this.preferences.alignment_for_arguments_in_allocation_expression, > argumentLength, > this.scribe.scanner.currentPosition); >@@ -2530,7 +2589,7 @@ > this.scribe.printNewLine(); > } > Alignment arrayInitializerAlignment =this.scribe.createAlignment( >- "array_initializer",//$NON-NLS-1$ >+ Alignment.ARRAY_INITIALIZER, > this.preferences.alignment_for_expressions_in_array_initializer, > Alignment.R_OUTERMOST, > expressionsLength, >@@ -2803,7 +2862,12 @@ > this.scribe.space(); > } > >- Alignment assignmentAlignment = this.scribe.createAlignment("assignmentAlignment", this.preferences.alignment_for_assignment, Alignment.R_OUTERMOST, 1, this.scribe.scanner.currentPosition); //$NON-NLS-1$ >+ Alignment assignmentAlignment = this.scribe.createAlignment( >+ Alignment.ASSIGNMENT, >+ this.preferences.alignment_for_assignment, >+ Alignment.R_OUTERMOST, >+ 1, >+ this.scribe.scanner.currentPosition); > this.scribe.enterAlignment(assignmentAlignment); > boolean ok = false; > do { >@@ -3128,7 +3192,12 @@ > if (this.preferences.insert_space_after_assignment_operator) { > this.scribe.space(); > } >- Alignment assignmentAlignment = this.scribe.createAlignment("compoundAssignmentAlignment", this.preferences.alignment_for_assignment, Alignment.R_OUTERMOST, 1, this.scribe.scanner.currentPosition); //$NON-NLS-1$ >+ Alignment assignmentAlignment = this.scribe.createAlignment( >+ Alignment.COMPOUND_ASSIGNMENT, >+ this.preferences.alignment_for_assignment, >+ Alignment.R_OUTERMOST, >+ 1, >+ this.scribe.scanner.currentPosition); > this.scribe.enterAlignment(assignmentAlignment); > boolean ok = false; > do { >@@ -3162,7 +3231,7 @@ > conditionalExpression.condition.traverse(this, scope); > > Alignment conditionalExpressionAlignment =this.scribe.createAlignment( >- "conditionalExpression", //$NON-NLS-1$ >+ Alignment.CONDITIONAL_EXPRESSION, > this.preferences.alignment_for_conditional_expression, > 2, > this.scribe.scanner.currentPosition); >@@ -3567,7 +3636,7 @@ > } > int argumentLength = arguments.length; > Alignment argumentsAlignment =this.scribe.createAlignment( >- "explicit_constructor_call",//$NON-NLS-1$ >+ Alignment.EXPLICIT_CONSTRUCTOR_CALL, > this.preferences.alignment_for_arguments_in_explicit_constructor_call, > argumentLength, > this.scribe.scanner.currentPosition); >@@ -3826,7 +3895,7 @@ > } > } else if (elseStatement == null && this.preferences.keep_simple_if_on_one_line) { > Alignment compactIfAlignment = this.scribe.createAlignment( >- "compactIf", //$NON-NLS-1$ >+ Alignment.COMPACT_IF, > this.preferences.alignment_for_compact_if, > Alignment.R_OUTERMOST, > 1, >@@ -4064,14 +4133,14 @@ > messageSend.receiver.traverse(this, scope); > int alignmentMode = this.preferences.alignment_for_selector_in_method_invocation; > messageAlignment = this.scribe.createAlignment( >- "messageAlignment", //$NON-NLS-1$ >+ Alignment.MESSAGE_SEND, > alignmentMode, > 1, > this.scribe.scanner.currentPosition); > this.scribe.enterAlignment(messageAlignment); > boolean ok = false; > do { >- switch (alignmentMode) { >+ switch (alignmentMode & Alignment.SPLIT_MASK) { > case Alignment.M_COMPACT_SPLIT: > case Alignment.M_NEXT_PER_LINE_SPLIT: > messageAlignment.startingColumn = this.scribe.column; >@@ -4134,7 +4203,7 @@ > > // Create alignment > Alignment methodDeclAlignment = this.scribe.createAlignment( >- "methodDeclaration",//$NON-NLS-1$ >+ Alignment.METHOD_DECLARATION, > this.preferences.alignment_for_method_declaration, > Alignment.R_INNERMOST, > 3, >@@ -4289,7 +4358,7 @@ > if (memberValuePairs != null) { > int length = memberValuePairs.length; > Alignment annotationAlignment = this.scribe.createAlignment( >- "annotationMemberValuePairs",//$NON-NLS-1$ >+ Alignment.ANNOTATION_MEMBERS_VALUE_PAIRS, > this.preferences.alignment_for_arguments_in_annotation, > length, > this.scribe.scanner.currentPosition); >@@ -4637,7 +4706,7 @@ > } > int argumentLength = arguments.length; > Alignment argumentsAlignment =this.scribe.createAlignment( >- "allocation",//$NON-NLS-1$ >+ Alignment.ALLOCATION, > this.preferences.alignment_for_arguments_in_qualified_allocation_expression, > argumentLength, > this.scribe.scanner.currentPosition); >@@ -4896,7 +4965,12 @@ > this.scribe.printComment(); > ASTNode[] fragments = stringLiteral.literals; > int fragmentsSize = stringLiteral.counter; >- Alignment binaryExpressionAlignment = this.scribe.createAlignment("binaryExpressionAlignment", this.preferences.alignment_for_binary_expression, Alignment.R_OUTERMOST, fragmentsSize, this.scribe.scanner.currentPosition); //$NON-NLS-1$ >+ Alignment binaryExpressionAlignment = this.scribe.createAlignment( >+ Alignment.BINARY_EXPRESSION, >+ this.preferences.alignment_for_binary_expression, >+ Alignment.R_OUTERMOST, >+ fragmentsSize, >+ this.scribe.scanner.currentPosition); > this.scribe.enterAlignment(binaryExpressionAlignment); > boolean ok = false; > do { >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.204 >diff -u -r1.204 Scribe.java >--- formatter/org/eclipse/jdt/internal/formatter/Scribe.java 23 Mar 2010 10:40:33 -0000 1.204 >+++ formatter/org/eclipse/jdt/internal/formatter/Scribe.java 23 Apr 2010 00:21:58 -0000 >@@ -595,24 +595,24 @@ > return INVALID_TOKEN; > } > >- public Alignment createAlignment(String name, int mode, int count, int sourceRestart){ >- return createAlignment(name, mode, Alignment.R_INNERMOST, count, sourceRestart); >+ public Alignment createAlignment(int kind, int mode, int count, int sourceRestart){ >+ return createAlignment(kind, mode, Alignment.R_INNERMOST, count, sourceRestart); > } > >- public Alignment createAlignment(String name, int mode, int count, int sourceRestart, boolean adjust){ >- return createAlignment(name, mode, Alignment.R_INNERMOST, count, sourceRestart, adjust); >+ public Alignment createAlignment(int kind, int mode, int count, int sourceRestart, boolean adjust){ >+ return createAlignment(kind, mode, Alignment.R_INNERMOST, count, sourceRestart, adjust); > } > >- public Alignment createAlignment(String name, int mode, int tieBreakRule, int count, int sourceRestart){ >- return createAlignment(name, mode, tieBreakRule, count, sourceRestart, this.formatter.preferences.continuation_indentation, false); >+ public Alignment createAlignment(int kind, int mode, int tieBreakRule, int count, int sourceRestart){ >+ return createAlignment(kind, mode, tieBreakRule, count, sourceRestart, this.formatter.preferences.continuation_indentation, false); > } > >- public Alignment createAlignment(String name, int mode, int count, int sourceRestart, int continuationIndent, boolean adjust){ >- return createAlignment(name, mode, Alignment.R_INNERMOST, count, sourceRestart, continuationIndent, adjust); >+ public Alignment createAlignment(int kind, int mode, int count, int sourceRestart, int continuationIndent, boolean adjust){ >+ return createAlignment(kind, mode, Alignment.R_INNERMOST, count, sourceRestart, continuationIndent, adjust); > } > >- public Alignment createAlignment(String name, int mode, int tieBreakRule, int count, int sourceRestart, int continuationIndent, boolean adjust){ >- Alignment alignment = new Alignment(name, mode, tieBreakRule, this, count, sourceRestart, continuationIndent); >+ public Alignment createAlignment(int kind, int mode, int tieBreakRule, int count, int sourceRestart, int continuationIndent, boolean adjust){ >+ Alignment alignment = new Alignment(kind, mode, tieBreakRule, this, count, sourceRestart, continuationIndent); > // adjust break indentation > if (adjust && this.memberAlignment != null) { > Alignment current = this.memberAlignment; >@@ -674,8 +674,8 @@ > return alignment; > } > >- public Alignment createMemberAlignment(String name, int mode, int count, int sourceRestart) { >- Alignment mAlignment = createAlignment(name, mode, Alignment.R_INNERMOST, count, sourceRestart); >+ public Alignment createMemberAlignment(int kind, int mode, int count, int sourceRestart) { >+ Alignment mAlignment = createAlignment(kind, mode, Alignment.R_INNERMOST, count, sourceRestart); > mAlignment.breakIndentationLevel = this.indentationLevel; > return mAlignment; > } >@@ -724,13 +724,6 @@ > this.memberAlignment = current.enclosing; > } > >- public Alignment getAlignment(String name){ >- if (this.currentAlignment != null) { >- return this.currentAlignment.getAlignment(name); >- } >- return null; >- } >- > /** > * Answer actual indentation level based on true column position > * @return int >@@ -1105,11 +1098,11 @@ > // skip > } > this.scanner.resetTo(currentTokenStartPosition, this.scannerEndPosition - 1); >- boolean canUseAlignmentIndentation = (nextToken != TerminalTokens.TokenNameLBRACE || !this.currentAlignment.name.equals("localDeclarationAssignmentAlignment")); //$NON-NLS-1$ >+ boolean canUseAlignmentIndentation = (nextToken != TerminalTokens.TokenNameLBRACE || this.currentAlignment.kind != Alignment.LOCAL_DECLARATION_ASSIGNMENT); > if (canUseAlignmentIndentation && > (!this.formatBrace || >- this.currentAlignment.name.equals("array_initializer") || //$NON-NLS-1$ >- this.currentAlignment.name.equals("binaryExpressionAlignment")) && //$NON-NLS-1$ >+ this.currentAlignment.kind == Alignment.ARRAY_INITIALIZER || >+ this.currentAlignment.kind == Alignment.BINARY_EXPRESSION) && > this.indentationLevel < this.currentAlignment.breakIndentationLevel) { > this.indentationLevel = this.currentAlignment.breakIndentationLevel; > } >@@ -1219,10 +1212,25 @@ > // look for outermost breakable one > int relativeDepth = 0, outerMostDepth = -1; > Alignment targetAlignment = this.currentAlignment; >+ int previousKind = -1; >+ boolean insideMessageArguments = false; >+ boolean insideMessageSend = false; > while (targetAlignment != null){ >- if (targetAlignment.tieBreakRule == Alignment.R_OUTERMOST && targetAlignment.couldBreak()){ >+ boolean couldBreak = targetAlignment.tieBreakRule == Alignment.R_OUTERMOST || >+ ((insideMessageArguments || insideMessageSend) && targetAlignment.kind == Alignment.MESSAGE_ARGUMENTS >+ && (!targetAlignment.wasReset() || previousKind != Alignment.MESSAGE_SEND)); >+ if (couldBreak && targetAlignment.couldBreak()){ > outerMostDepth = relativeDepth; > } >+ switch (targetAlignment.kind) { >+ case Alignment.MESSAGE_ARGUMENTS: >+ insideMessageArguments = true; >+ break; >+ case Alignment.MESSAGE_SEND: >+ insideMessageSend = true; >+ break; >+ } >+ previousKind = targetAlignment.kind; > targetAlignment = targetAlignment.enclosing; > relativeDepth++; > } >@@ -1232,14 +1240,41 @@ > // look for innermost breakable one > relativeDepth = 0; > targetAlignment = this.currentAlignment; >- while (targetAlignment != null){ >- if (targetAlignment.couldBreak()){ >- throw new AlignmentException(AlignmentException.LINE_TOO_LONG, relativeDepth); >+ AlignmentException alignmentException = null; >+ int msgArgsDepth = -1; >+ while (targetAlignment != null) { >+ if (targetAlignment.kind == Alignment.MESSAGE_ARGUMENTS) { >+ msgArgsDepth = relativeDepth; >+ } >+ if (alignmentException == null) { >+ if (targetAlignment.couldBreak()) { >+ // do not throw the exception immediately to have a chance to reset >+ // previously broken alignments (see bug 203588) >+ alignmentException = new AlignmentException(AlignmentException.LINE_TOO_LONG, relativeDepth); >+ } >+ } else if (targetAlignment.wasSplit) { >+ // reset the nearest already broken outermost alignment. >+ // Note that it's not done twice to avoid infinite loop while raising >+ // the exception on an innermost alignment... >+ if (!targetAlignment.wasReset()) { >+ targetAlignment.reset(); >+ if (msgArgsDepth > alignmentException.relativeDepth) { >+ alignmentException.relativeDepth = msgArgsDepth; >+ } >+ throw alignmentException; >+ } > } > targetAlignment = targetAlignment.enclosing; > relativeDepth++; > } >+ if (alignmentException != null) { >+ throw alignmentException; >+ } > // did not find any breakable location - proceed >+ if (this.currentAlignment != null) { >+ this.currentAlignment.blockAlign = false; >+ this.currentAlignment.tooLong = true; >+ } > } > > /* >@@ -2560,7 +2595,7 @@ > commentIndentationLevel = this.column - 1; > } > } else { >- if (this.currentAlignment != null && this.currentAlignment.name.equals("array_initializer") && //$NON-NLS-1$ >+ if (this.currentAlignment != null && this.currentAlignment.kind == Alignment.ARRAY_INITIALIZER && > this.indentationLevel < this.currentAlignment.breakIndentationLevel && > this.lastLineComment.lines > 0) > { >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.38 >diff -u -r1.38 Alignment.java >--- formatter/org/eclipse/jdt/internal/formatter/align/Alignment.java 4 Jan 2010 19:48:25 -0000 1.38 >+++ formatter/org/eclipse/jdt/internal/formatter/align/Alignment.java 23 Apr 2010 00:21:58 -0000 >@@ -10,6 +10,7 @@ > *******************************************************************************/ > package org.eclipse.jdt.internal.formatter.align; > >+import org.eclipse.core.runtime.Assert; > import org.eclipse.jdt.internal.formatter.Location; > import org.eclipse.jdt.internal.formatter.Scribe; > >@@ -20,8 +21,60 @@ > */ > public class Alignment { > >+ // Kind of alignment >+ public int kind; >+ public static final int ALLOCATION = 1; >+ public static final int ANNOTATION_MEMBERS_VALUE_PAIRS = 2; >+ public static final int ARRAY_INITIALIZER = 3; >+ public static final int ASSIGNMENT = 4; >+ public static final int BINARY_EXPRESSION = 5; >+ public static final int CASCADING_MESSAGE_SEND = 6; >+ public static final int COMPACT_IF = 7; >+ public static final int COMPOUND_ASSIGNMENT = 8; >+ public static final int CONDITIONAL_EXPRESSION = 9; >+ public static final int ENUM_CONSTANTS = 10; >+ public static final int ENUM_CONSTANTS_ARGUMENTS = 11; >+ public static final int EXPLICIT_CONSTRUCTOR_CALL = 12; >+ public static final int FIELD_DECLARATION_ASSIGNMENT = 13; >+ public static final int LOCAL_DECLARATION_ASSIGNMENT = 14; >+ public static final int MESSAGE_ARGUMENTS = 15; >+ public static final int MESSAGE_SEND = 16; >+ public static final int METHOD_ARGUMENTS = 17; >+ public static final int METHOD_DECLARATION = 18; >+ public static final int MULTIPLE_FIELD = 19; >+ public static final int SUPER_CLASS = 20; >+ public static final int SUPER_INTERFACES = 21; >+ public static final int THROWS = 22; >+ public static final int TYPE_MEMBERS = 23; >+ > // name of alignment > public String name; >+ public static final String[] NAMES = { >+ "", //$NON-NLS-1$ >+ "allocation", //$NON-NLS-1$ >+ "annotationMemberValuePairs", //$NON-NLS-1$ >+ "array_initializer", //$NON-NLS-1$ >+ "assignmentAlignment", //$NON-NLS-1$ >+ "binaryExpressionAlignment", //$NON-NLS-1$ >+ "cascadingMessageSendAlignment", //$NON-NLS-1$ >+ "compactIf", //$NON-NLS-1$ >+ "compoundAssignmentAlignment", //$NON-NLS-1$ >+ "conditionalExpression", //$NON-NLS-1$ >+ "enumConstants", //$NON-NLS-1$ >+ "enumConstantArguments", //$NON-NLS-1$ >+ "explicit_constructor_call", //$NON-NLS-1$ >+ "fieldDeclarationAssignmentAlignment", //$NON-NLS-1$ >+ "localDeclarationAssignmentAlignment", //$NON-NLS-1$ >+ "messageArguments", //$NON-NLS-1$ >+ "messageAlignment", //$NON-NLS-1$ >+ "methodArguments", //$NON-NLS-1$ >+ "methodDeclaration", //$NON-NLS-1$ >+ "multiple_field", //$NON-NLS-1$ >+ "superclass", //$NON-NLS-1$ >+ "superInterfaces", //$NON-NLS-1$ >+ "throws", //$NON-NLS-1$ >+ "typeMembers", //$NON-NLS-1$ >+ }; > > // link to enclosing alignment > public Alignment enclosing; >@@ -45,9 +98,14 @@ > public int shiftBreakIndentationLevel; > public int[] fragmentBreaks; > public boolean wasSplit; >+ public boolean blockAlign = false; >+ public boolean tooLong = false; > > public Scribe scribe; > >+ // reset >+ private boolean reset = false; >+ > /* > * Alignment modes > */ >@@ -133,9 +191,11 @@ > public static final int CHUNK_ENUM = 4; > > // location to align and break on. >- public Alignment(String name, int mode, int tieBreakRule, Scribe scribe, int fragmentCount, int sourceRestart, int continuationIndent){ >+ public Alignment(int kind, int mode, int tieBreakRule, Scribe scribe, int fragmentCount, int sourceRestart, int continuationIndent){ > >- this.name = name; >+ Assert.isTrue(kind >=ALLOCATION && kind <=TYPE_MEMBERS); >+ this.kind = kind; >+ this.name = NAMES[kind]; > this.location = new Location(scribe, sourceRestart); > this.mode = mode; > this.tieBreakRule = tieBreakRule; >@@ -174,9 +234,9 @@ > } > } > >- public boolean checkChunkStart(int kind, int startIndex, int sourceRestart) { >- if (this.chunkKind != kind) { >- this.chunkKind = kind; >+ public boolean checkChunkStart(int chunk, int startIndex, int sourceRestart) { >+ if (this.chunkKind != chunk) { >+ this.chunkKind = chunk; > > // when redoing same chunk alignment, must not reset > if (startIndex != this.chunkStartIndex) { >@@ -232,6 +292,61 @@ > } > return depth; > } >+ >+ /** >+ * Returns whether the alignment can be aligned or not. >+ * Only used for message send alignment, it currently blocks its alignment >+ * when it's at the first nesting level of a message send. It allow to save >+ * space on the argument broken line by reducing the number of indentations. >+ */ >+ public boolean canAlign() { >+ if (this.tooLong) { >+ return true; >+ } >+ boolean canAlign = true; >+ Alignment enclosingAlignment = this.enclosing; >+ while (enclosingAlignment != null) { >+ switch (enclosingAlignment.kind) { >+ case Alignment.ALLOCATION: >+ case Alignment.MESSAGE_ARGUMENTS: >+ // message send inside arguments, avoid to align >+ if (enclosingAlignment.isWrapped() && >+ (enclosingAlignment.fragmentIndex > 0 || enclosingAlignment.fragmentCount < 2)) { >+ return !this.blockAlign; >+ } >+ if (enclosingAlignment.tooLong) { >+ return true; >+ } >+ canAlign = false; >+ break; >+ case Alignment.MESSAGE_SEND: >+ // multiple depth of message send, hence allow current to align >+ switch (this.kind) { >+ case Alignment.ALLOCATION: >+ case Alignment.MESSAGE_ARGUMENTS: >+ case Alignment.MESSAGE_SEND: >+ Alignment superEnclosingAlignment = enclosingAlignment.enclosing; >+ while (superEnclosingAlignment != null) { >+ switch (superEnclosingAlignment.kind) { >+ case Alignment.ALLOCATION: >+ case Alignment.MESSAGE_ARGUMENTS: >+ case Alignment.MESSAGE_SEND: >+ // block the alignment of the intermediate message send >+ if (this.scribe.nlsTagCounter == 0) { >+ enclosingAlignment.blockAlign = true; >+ } >+ return !this.blockAlign; >+ } >+ superEnclosingAlignment = superEnclosingAlignment.enclosing; >+ } >+ break; >+ } >+ return !this.blockAlign; >+ } >+ enclosingAlignment = enclosingAlignment.enclosing; >+ } >+ return canAlign && !this.blockAlign; >+ } > > public boolean couldBreak(){ > int i; >@@ -329,12 +444,17 @@ > return false; // cannot split better > } > >- public Alignment getAlignment(String targetName) { >- >- if (targetName.equals(this.name)) return this; >- if (this.enclosing == null) return null; >+ public boolean isWrapped() { >+ return this.fragmentBreaks[this.fragmentIndex] == BREAK; >+ } > >- return this.enclosing.getAlignment(targetName); >+ public int wrappedIndex() { >+ for (int i = 0, max = this.fragmentCount; i < max; i++) { >+ if (this.fragmentBreaks[i] == BREAK) { >+ return i; >+ } >+ } >+ return -1; > } > > // perform alignment effect for current fragment >@@ -366,6 +486,7 @@ > // reset fragment indentation/break status > public void reset() { > >+ this.wasSplit = false; > if (this.fragmentCount > 0){ > this.fragmentIndentations = new int[this.fragmentCount]; > this.fragmentBreaks = new int[this.fragmentCount]; >@@ -375,6 +496,7 @@ > if ((this.mode & M_FORCE) != 0) { > couldBreak(); > } >+ this.reset = true; > } > > public void toFragmentsString(StringBuffer buffer){ >@@ -397,6 +519,10 @@ > // First line is for class and name > buffer.append(indentation); > buffer >+ .append("<kind: ") //$NON-NLS-1$ >+ .append(this.kind) >+ .append("> "); //$NON-NLS-1$ >+ buffer > .append("<name: ") //$NON-NLS-1$ > .append(this.name) > .append(">\n"); //$NON-NLS-1$ >@@ -463,12 +589,7 @@ > } > } > >- public boolean isWrapped() { >- for (int i = 0, max = this.fragmentCount; i < max; i++) { >- if (this.fragmentBreaks[i] == BREAK) { >- return true; >- } >- } >- return false; >+ public boolean wasReset() { >+ return this.reset; > } > } >#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.26 >diff -u -r1.26 FormatterBugsTests.java >--- src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java 20 Apr 2010 11:50:07 -0000 1.26 >+++ src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java 23 Apr 2010 00:22:04 -0000 >@@ -14,6 +14,7 @@ > > import junit.framework.Test; > >+import org.eclipse.jdt.core.JavaCore; > import org.eclipse.jdt.core.JavaModelException; > import org.eclipse.jdt.core.formatter.CodeFormatter; > import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; >@@ -634,6 +635,530 @@ > } > > /** >+ * @bug 59891: [formatter] the code formatter doesn't respect my new lines >+ * @test Ensure that the formatter keep line breaks wrapping set by users in the code >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=59891" >+ */ >+//static { TESTS_PREFIX = "testBug059891"; } >+public void testBug059891_01() throws JavaModelException { >+ this.formatterPrefs.page_width = 40; >+ String source = >+ "public class X01 {\n" + >+ " void test() {\n" + >+ " foo(bar(1, 2, 3, 4), bar(5, 6, 7, 8));\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X01 {\n" + >+ " void test() {\n" + >+ " foo(bar(1, 2, 3, 4),\n" + >+ " bar(5, 6, 7, 8));\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug059891_01b() throws JavaModelException { >+ this.formatterPrefs = null; >+ this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "40"); >+ this.formatterOptions.put( >+ DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, >+ DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); >+ String source = >+ "public class X01 {\n" + >+ " void test() {\n" + >+ " foo(bar(1, 2, 3, 4), bar(5, 6, 7, 8));\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X01 {\n" + >+ " void test() {\n" + >+ " foo(bar(1, 2, 3, 4),\n" + >+ " bar(5, 6, 7, 8));\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug059891_02() throws JavaModelException { >+ this.formatterPrefs.page_width = 40; >+ String source = >+ "public class X02 {\n" + >+ " void test() {\n" + >+ " foo(bar(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), bar(11, 12, 13, 14, 15, 16, 17, 18, 19, 20));\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X02 {\n" + >+ " void test() {\n" + >+ " foo(bar(1, 2, 3, 4, 5, 6, 7, 8,\n" + >+ " 9, 10),\n" + >+ " bar(11, 12, 13, 14, 15,\n" + >+ " 16, 17, 18, 19,\n" + >+ " 20));\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug059891_02b() throws JavaModelException { >+ this.formatterPrefs = null; >+ this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "40"); >+ this.formatterOptions.put( >+ DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, >+ DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); >+ String source = >+ "public class X02 {\n" + >+ " void test() {\n" + >+ " foo(bar(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), bar(11, 12, 13, 14, 15, 16, 17, 18, 19, 20));\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X02 {\n" + >+ " void test() {\n" + >+ " foo(bar(1, 2, 3, 4, 5, 6, 7, 8,\n" + >+ " 9, 10),\n" + >+ " bar(11, 12, 13, 14, 15, 16,\n" + >+ " 17, 18, 19, 20));\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug059891_03() throws JavaModelException { >+ this.formatterPrefs.page_width = 40; >+ String source = >+ "public class X03 {\n" + >+ " void test() {\n" + >+ " foo(bar(1, 2, 3, 4), bar(5, 6, 7, 8), bar(9, 10, 11, 12));\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X03 {\n" + >+ " void test() {\n" + >+ " foo(bar(1, 2, 3, 4),\n" + >+ " bar(5, 6, 7, 8),\n" + >+ " bar(9, 10, 11, 12));\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug059891_03b() throws JavaModelException { >+ this.formatterPrefs = null; >+ this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "40"); >+ this.formatterOptions.put( >+ DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, >+ DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); >+ String source = >+ "public class X03 {\n" + >+ " void test() {\n" + >+ " foo(bar(1, 2, 3, 4), bar(5, 6, 7, 8), bar(9, 10, 11, 12));\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X03 {\n" + >+ " void test() {\n" + >+ " foo(bar(1, 2, 3, 4),\n" + >+ " bar(5, 6, 7, 8),\n" + >+ " bar(9, 10, 11, 12));\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=146175 >+public void testBug059891_146175() throws JavaModelException { >+ String source = >+ "public class FormatterDemo {\n" + >+ "\n" + >+ " public void fooBar() {\n" + >+ " SomeOtherClass instanceOfOtherClass = new SomeOtherClass();\n" + >+ "\n" + >+ " /* The following statement demonstrates the formatter issue */\n" + >+ " SomeOtherClass.someMethodInInnerClass(\n" + >+ " instanceOfOtherClass.anotherMethod(\"Value of paramter 1\"),\n" + >+ " instanceOfOtherClass.anotherMethod(\"Value of paramter 2\"));\n" + >+ "\n" + >+ " }\n" + >+ "\n" + >+ " private static class SomeOtherClass {\n" + >+ " public static void someMethodInInnerClass(\n" + >+ " String param1,\n" + >+ " String param2) {\n" + >+ " }\n" + >+ " public String anotherMethod(String par) {\n" + >+ " return par;\n" + >+ " }\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class FormatterDemo {\n" + >+ "\n" + >+ " public void fooBar() {\n" + >+ " SomeOtherClass instanceOfOtherClass = new SomeOtherClass();\n" + >+ "\n" + >+ " /* The following statement demonstrates the formatter issue */\n" + >+ " SomeOtherClass.someMethodInInnerClass(\n" + >+ " instanceOfOtherClass.anotherMethod(\"Value of paramter 1\"),\n" + >+ " instanceOfOtherClass.anotherMethod(\"Value of paramter 2\"));\n" + >+ "\n" + >+ " }\n" + >+ "\n" + >+ " private static class SomeOtherClass {\n" + >+ " public static void someMethodInInnerClass(String param1, String param2) {\n" + >+ " }\n" + >+ "\n" + >+ " public String anotherMethod(String par) {\n" + >+ " return par;\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=164093 >+public void testBug059891_164093_01() throws JavaModelException { >+ this.formatterPrefs = null; >+ this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "30"); >+ this.formatterOptions.put( >+ DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, >+ DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); >+ String source = >+ "public class Test {\n" + >+ " int someLongMethodName(int foo, boolean bar, String yetAnotherArg) {\n" + >+ " return 0;\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class Test {\n" + >+ " int someLongMethodName( int foo,\n" + >+ " boolean bar,\n" + >+ " String yetAnotherArg) {\n" + >+ " return 0;\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug059891_164093_02() throws JavaModelException { >+ this.formatterPrefs = null; >+ this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "55"); >+ this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); >+ this.formatterOptions.put( >+ DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION, >+ DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); >+ String source = >+ "public class X01 {\n" + >+ " void foo() {\n" + >+ " someIdentifier(someArg).someMethodName().someMethodName(foo, bar).otherMethod(arg0, arg1);\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X01 {\n" + >+ " void foo() {\n" + >+ " someIdentifier(someArg).someMethodName()\n" + >+ " .someMethodName(foo,\n" + >+ " bar)\n" + >+ " .otherMethod(arg0, arg1);\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=203588 >+public void testBug059891_203588() throws JavaModelException { >+ String source = >+ "public class Test {\n" + >+ "public void a()\n" + >+ "{\n" + >+ " if(true)\n" + >+ " {\n" + >+ " allocation.add(idx_ta + 1, Double.valueOf(allocation.get(idx_ta).doubleValue() + q));\n" + >+ " }\n" + >+ "}\n" + >+ "}\n"; >+ formatSource(source, >+ "public class Test {\n" + >+ " public void a() {\n" + >+ " if (true) {\n" + >+ " allocation.add(idx_ta + 1,\n" + >+ " Double.valueOf(allocation.get(idx_ta).doubleValue() + q));\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+// wksp1 >+public void testBug059891_wksp1_01() throws JavaModelException { >+ String source = >+ "public class X01 {\n" + >+ " private void reportError(String name) throws ParseError {\n" + >+ " throw new ParseError(MessageFormat.format(AntDTDSchemaMessages.getString(\"NfmParser.Ambiguous\"), new String[]{name})); //$NON-NLS-1$\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X01 {\n" + >+ " private void reportError(String name) throws ParseError {\n" + >+ " throw new ParseError(\n" + >+ " MessageFormat.format(\n" + >+ " AntDTDSchemaMessages.getString(\"NfmParser.Ambiguous\"), new String[] { name })); //$NON-NLS-1$\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug059891_wksp1_02() throws JavaModelException { >+ String source = >+ "public class X02 {\n" + >+ " private void parseBuildFile(Project project) {\n" + >+ " if (!buildFile.exists()) {\n" + >+ " throw new BuildException(MessageFormat.format(InternalAntMessages.getString(\"InternalAntRunner.Buildfile__{0}_does_not_exist_!_1\"), //$NON-NLS-1$\n" + >+ " new String[]{buildFile.getAbsolutePath()}));\n" + >+ " }\n" + >+ " if (!buildFile.isFile()) {\n" + >+ " throw new BuildException(MessageFormat.format(InternalAntMessages.getString(\"InternalAntRunner.Buildfile__{0}_is_not_a_file_1\"), //$NON-NLS-1$\n" + >+ " new String[]{buildFile.getAbsolutePath()}));\n" + >+ " }\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X02 {\n" + >+ " private void parseBuildFile(Project project) {\n" + >+ " if (!buildFile.exists()) {\n" + >+ " throw new BuildException(\n" + >+ " MessageFormat.format(\n" + >+ " InternalAntMessages\n" + >+ " .getString(\"InternalAntRunner.Buildfile__{0}_does_not_exist_!_1\"), //$NON-NLS-1$\n" + >+ " new String[] { buildFile.getAbsolutePath() }));\n" + >+ " }\n" + >+ " if (!buildFile.isFile()) {\n" + >+ " throw new BuildException(\n" + >+ " MessageFormat.format(\n" + >+ " InternalAntMessages\n" + >+ " .getString(\"InternalAntRunner.Buildfile__{0}_is_not_a_file_1\"), //$NON-NLS-1$\n" + >+ " new String[] { buildFile.getAbsolutePath() }));\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug059891_wksp1_03() throws JavaModelException { >+ String source = >+ "public class X03 {\n" + >+ "\n" + >+ " protected void foo() {\n" + >+ " printTargets(project, subNames, null, InternalAntMessages.getString(\"InternalAntRunner.Subtargets__5\"), 0); //$NON-NLS-1$\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X03 {\n" + >+ "\n" + >+ " protected void foo() {\n" + >+ " printTargets(project, subNames, null,\n" + >+ " InternalAntMessages\n" + >+ " .getString(\"InternalAntRunner.Subtargets__5\"), 0); //$NON-NLS-1$\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug059891_wksp1_04() throws JavaModelException { >+ String source = >+ "public class X04 {\n" + >+ " void foo() {\n" + >+ " if (AntUIPlugin.getDefault().getPreferenceStore().getBoolean(IAntUIPreferenceConstants.OUTLINE_LINK_WITH_EDITOR)) {\n" + >+ " synchronizeOutlinePage(node, true);\n" + >+ " }\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X04 {\n" + >+ " void foo() {\n" + >+ " if (AntUIPlugin.getDefault().getPreferenceStore()\n" + >+ " .getBoolean(IAntUIPreferenceConstants.OUTLINE_LINK_WITH_EDITOR)) {\n" + >+ " synchronizeOutlinePage(node, true);\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug059891_wksp1_05() throws JavaModelException { >+ String source = >+ "public class X05 {\n" + >+ "void foo() {\n" + >+ " if (false && AntUIPlugin.getDefault().getPreferenceStore().getBoolean(AntEditorPreferenceConstants.TEMPLATES_USE_CODEFORMATTER)) {\n" + >+ " }\n" + >+ "}\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X05 {\n" + >+ " void foo() {\n" + >+ " if (false && AntUIPlugin\n" + >+ " .getDefault()\n" + >+ " .getPreferenceStore()\n" + >+ " .getBoolean(\n" + >+ " AntEditorPreferenceConstants.TEMPLATES_USE_CODEFORMATTER)) {\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+// TODO Improve this formatting as it let the message send argument in one line over the max width >+public void testBug059891_wksp1_06() throws JavaModelException { >+ String source = >+ "public class X06 {\n" + >+ " public void launch() {\n" + >+ " try {\n" + >+ " if ((javaProject == null) || !javaProject.exists()) {\n" + >+ " abort(PDEPlugin________.getResourceString(\"JUnitLaunchConfig_____\"), null, IJavaLaunchConfigurationConstants.ERR_NOT_A_JAVA_PROJECT);\n" + >+ " }\n" + >+ " } catch (CoreException e) {\n" + >+ " }\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X06 {\n" + >+ " public void launch() {\n" + >+ " try {\n" + >+ " if ((javaProject == null) || !javaProject.exists()) {\n" + >+ " abort(PDEPlugin________\n" + >+ " .getResourceString(\"JUnitLaunchConfig_____\"),\n" + >+ " null,\n" + >+ " IJavaLaunchConfigurationConstants.ERR_NOT_A_JAVA_PROJECT);\n" + >+ " }\n" + >+ " } catch (CoreException e) {\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug059891_wksp1_07() throws JavaModelException { >+ String source = >+ "public class X07 {\n" + >+ " void foo() {\n" + >+ " if (true) {\n" + >+ " configureAntObject(result, element, task, task.getTaskName(), InternalCoreAntMessages.getString(\"AntCorePreferences.No_library_for_task\")); //$NON-NLS-1$\n" + >+ " }\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X07 {\n" + >+ " void foo() {\n" + >+ " if (true) {\n" + >+ " configureAntObject(\n" + >+ " result,\n" + >+ " element,\n" + >+ " task,\n" + >+ " task.getTaskName(),\n" + >+ " InternalCoreAntMessages\n" + >+ " .getString(\"AntCorePreferences.No_library_for_task\")); //$NON-NLS-1$\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug059891_wksp1_08() throws JavaModelException { >+ String source = >+ "public class X08 {\n" + >+ " public void foo() {\n" + >+ " if (true) {\n" + >+ " IStatus status= new Status(IStatus.ERROR, AntCorePlugin.PI_ANTCORE, AntCorePlugin.ERROR_RUNNING_BUILD, MessageFormat.format(InternalCoreAntMessages.getString(\"AntRunner.Already_in_progess\"), new String[]{buildFileLocation}), null); //$NON-NLS-1$\n" + >+ " }\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X08 {\n" + >+ " public void foo() {\n" + >+ " if (true) {\n" + >+ " IStatus status = new Status(\n" + >+ " IStatus.ERROR,\n" + >+ " AntCorePlugin.PI_ANTCORE,\n" + >+ " AntCorePlugin.ERROR_RUNNING_BUILD,\n" + >+ " MessageFormat.format(\n" + >+ " InternalCoreAntMessages\n" + >+ " .getString(\"AntRunner.Already_in_progess\"), new String[] { buildFileLocation }), null); //$NON-NLS-1$\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug059891_wksp1_09() throws JavaModelException { >+ String source = >+ "public class X09 {\n" + >+ " void foo() {\n" + >+ " if (true) {\n" + >+ " String secondFileName = secondDirectoryAbsolutePath + File.separator + currentFile.substring(firstDirectoryAbsolutePath.length() + 1);\n" + >+ " }\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X09 {\n" + >+ " void foo() {\n" + >+ " if (true) {\n" + >+ " String secondFileName = secondDirectoryAbsolutePath\n" + >+ " + File.separator\n" + >+ " + currentFile\n" + >+ " .substring(firstDirectoryAbsolutePath.length() + 1);\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug059891_wksp1_10() throws JavaModelException { >+ String source = >+ "public class X10 {\n" + >+ " void foo() {\n" + >+ " if (true) {\n" + >+ " if (true) {\n" + >+ " throw new BuildException(InternalAntMessages.getString(\"InternalAntRunner.Could_not_load_the_version_information._10\")); //$NON-NLS-1$\n" + >+ " }\n" + >+ " }\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X10 {\n" + >+ " void foo() {\n" + >+ " if (true) {\n" + >+ " if (true) {\n" + >+ " throw new BuildException(\n" + >+ " InternalAntMessages\n" + >+ " .getString(\"InternalAntRunner.Could_not_load_the_version_information._10\")); //$NON-NLS-1$\n" + >+ " }\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug059891_wksp1_11() throws JavaModelException { >+ String source = >+ "public class X11 {\n" + >+ " private void antFileNotFound() {\n" + >+ " reportError(AntLaunchConfigurationMessages.getString(\"AntLaunchShortcut.Unable\"), null); //$NON-NLS-1$ \n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X11 {\n" + >+ " private void antFileNotFound() {\n" + >+ " reportError(\n" + >+ " AntLaunchConfigurationMessages\n" + >+ " .getString(\"AntLaunchShortcut.Unable\"), null); //$NON-NLS-1$ \n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug059891_wksp1_12() throws JavaModelException { >+ String source = >+ "public class X12 {\n" + >+ " void foo() {\n" + >+ " if (this.fTests.size() == 0) {\n" + >+ " this.addTest(TestSuite\n" + >+ " .warning(\"No tests found in \" + theClass.getName())); //$NON-NLS-1$\n" + >+ " }\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class X12 {\n" + >+ " void foo() {\n" + >+ " if (this.fTests.size() == 0) {\n" + >+ " this.addTest(TestSuite\n" + >+ " .warning(\"No tests found in \" + theClass.getName())); //$NON-NLS-1$\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+ >+/** > * @bug 198074: [formatter] the code formatter doesn't respect my new lines > * @test Ensure that the formatter keep line breaks wrapping set by users in the code > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=198074" >@@ -1114,6 +1639,39 @@ > } > > /** >+ * @bug 203588: [formatter] Qualified invocation + binary expressions excessive wrap >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=203588" >+ */ >+public void testBug203588() throws JavaModelException { >+ String source = >+ "public class Test {\n" + >+ "void foo() {\n" + >+ " while (true) {\n" + >+ " if (patternChar\n" + >+ " != (isCaseSensitive\n" + >+ " ? name[iName]\n" + >+ " : Character.toLowerCase(name[iName]))\n" + >+ " && patternChar != \'?\') {\n" + >+ " return;\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" + >+ "}\n"; >+ formatSource(source, >+ "public class Test {\n" + >+ " void foo() {\n" + >+ " while (true) {\n" + >+ " if (patternChar != (isCaseSensitive ? name[iName] : Character\n" + >+ " .toLowerCase(name[iName])) && patternChar != \'?\') {\n" + >+ " return;\n" + >+ " }\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+ >+/** > * @bug 252556: [formatter] Spaces removed before formatted region of a compilation unit. > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=252556" > */ >@@ -2412,9 +2970,9 @@ > "\n" + > " void foo() {\n" + > " 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" + >+ " builder.append(\"abc\").append(\"def\").append(\"ghi\").append(\"jkl\")\n" + >+ " .append(\"mno\")\n" + >+ " .append(\"pqr\").append(\"stu\").append(\"vwx\").append(\"yz\");\n" + > " }\n" + > "}\n" > ); >@@ -2486,14 +3044,15 @@ > "\n" + > " void foo() {\n" + > " StringBuilder builder = new StringBuilder();\n" + >- " builder.append(\"abc\").append(\n" + >- " \"def\").append(\"ghi\")\n" + >- " .append(\"jkl\").append(\n" + >- " \"mno\")\n" + >- " .append(\"pqr\").append(\n" + >- " \"stu\").append(\n" + >- " \"vwx\").append(\n" + >- " \"yz\");\n" + >+ " builder.append(\"abc\")\n" + >+ " .append(\"def\")\n" + >+ " .append(\"ghi\")\n" + >+ " .append(\"jkl\")\n" + >+ " .append(\"mno\")\n" + >+ " .append(\"pqr\")\n" + >+ " .append(\"stu\")\n" + >+ " .append(\"vwx\")\n" + >+ " .append(\"yz\");\n" + > " }\n" + > "}\n" > ); >@@ -2516,15 +3075,15 @@ > "\n" + > " void foo() {\n" + > " StringBuilder builder = new StringBuilder();\n" + >- " builder.append(\"abc\").append(\n" + >- " \"def\")\n" + >- " .append(\"ghi\").append(\n" + >- " \"jkl\").append(\n" + >- " \"mno\")\n" + >- " .append(\"pqr\").append(\n" + >- " \"stu\").append(\n" + >- " \"vwx\").append(\n" + >- " \"yz\");\n" + >+ " builder.append(\"abc\")\n" + >+ " .append(\"def\")\n" + >+ " .append(\"ghi\")\n" + >+ " .append(\"jkl\")\n" + >+ " .append(\"mno\")\n" + >+ " .append(\"pqr\")\n" + >+ " .append(\"stu\")\n" + >+ " .append(\"vwx\")\n" + >+ " .append(\"yz\");\n" + > " }\n" + > "}\n" > ); >@@ -2548,15 +3107,15 @@ > "\n" + > " void foo() {\n" + > " StringBuilder builder = new StringBuilder();\n" + >- " builder.append(\"abc\").append(\n" + >- " \"def\")\n" + >- " .append(\"ghi\").append(\n" + >- " \"jkl\").append(\n" + >- " \"mno\")\n" + >- " .append(\"pqr\").append(\n" + >- " \"stu\").append(\n" + >- " \"vwx\")\n" + >- " .append(\"yz\");\n" + >+ " builder.append(\"abc\")\n" + >+ " .append(\"def\")\n" + >+ " .append(\"ghi\")\n" + >+ " .append(\"jkl\")\n" + >+ " .append(\"mno\")\n" + >+ " .append(\"pqr\")\n" + >+ " .append(\"stu\")\n" + >+ " .append(\"vwx\")\n" + >+ " .append(\"yz\");\n" + > " }\n" + > "}\n" > ); >@@ -4932,11 +5491,11 @@ > " if (point != null) {\n" + > " // Following message send was unnecessarily split\n" + > " sb.append(PATH_SMOOTH_QUAD_TO)\n" + >- " .append(\n" + >- " String.valueOf(midValue(point.x, point_plus1.x)))\n" + >+ " .append(String\n" + >+ " .valueOf(midValue(point.x, point_plus1.x)))\n" + > " .append(XML_SPACE)\n" + >- " .append(\n" + >- " String.valueOf(midValue(point.y, point_plus1.y)));\n" + >+ " .append(String\n" + >+ " .valueOf(midValue(point.y, point_plus1.y)));\n" + > " } else {\n" + > " break;\n" + > " }\n" + >@@ -4992,7 +5551,7 @@ > " null, // qualifier\n" + > " null, // stopKeyValue\n" + > " ScanController.GT // stopSearchOp\n" + >- " );\n" + >+ " );\n" + > " }\n" + > "\n" + > " }\n" + >Index: workspace/Formatter/test026/A_out.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/Formatter/test026/A_out.java,v >retrieving revision 1.3 >diff -u -r1.3 A_out.java >--- workspace/Formatter/test026/A_out.java 26 Nov 2003 17:40:44 -0000 1.3 >+++ workspace/Formatter/test026/A_out.java 23 Apr 2010 00:22:04 -0000 >@@ -7,7 +7,8 @@ > .someQuiteLongMessageSend("aaaaaaaaaaa", "bbbbbbbbbbbbb", > "cccccccc"); > Alignment expressionsAlignment = this.scribe.createAlignment( >- "expressions", Alignment.M_COMPACT_SPLIT >+ "expressions", >+ Alignment.M_COMPACT_SPLIT > + someMessageSend(Alignment.M_COMPACT_SPLIT, > Alignment.M_COMPACT_SPLIT, > Alignment.M_COMPACT_SPLIT, >Index: workspace/Formatter/test167/A_out.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/Formatter/test167/A_out.java,v >retrieving revision 1.2 >diff -u -r1.2 A_out.java >--- workspace/Formatter/test167/A_out.java 26 Nov 2003 17:40:44 -0000 1.2 >+++ workspace/Formatter/test167/A_out.java 23 Apr 2010 00:22:04 -0000 >@@ -2,8 +2,8 @@ > X(String s) { > } > protected void foo() { >- X a = new X(new StringBuffer("this").append("is").append("a").append( >- "long").append("argument").toString()) { >+ X a = new X(new StringBuffer("this").append("is").append("a") >+ .append("long").append("argument").toString()) { > public void run() { > } > }; >Index: workspace/Formatter/test169/A_out.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/Formatter/test169/A_out.java,v >retrieving revision 1.2 >diff -u -r1.2 A_out.java >--- workspace/Formatter/test169/A_out.java 26 Nov 2003 17:40:44 -0000 1.2 >+++ workspace/Formatter/test169/A_out.java 23 Apr 2010 00:22:04 -0000 >@@ -2,7 +2,7 @@ > X(String s) { > } > protected void foo() { >- cmd.createArgument().foo().test().error().setFile( >- destDir.getAbsoluteFile()); >+ cmd.createArgument().foo().test().error() >+ .setFile(destDir.getAbsoluteFile()); > } > } >\ No newline at end of file >Index: workspace/Formatter/test170/A_out.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/Formatter/test170/A_out.java,v >retrieving revision 1.2 >diff -u -r1.2 A_out.java >--- workspace/Formatter/test170/A_out.java 26 Nov 2003 17:40:44 -0000 1.2 >+++ workspace/Formatter/test170/A_out.java 23 Apr 2010 00:22:04 -0000 >@@ -2,7 +2,7 @@ > X(String s) { > } > protected void foo() { >- cmd.createArgument().foo().test().error().setFile( >- (Name) (destDir()).getAbsoluteFile()); >+ cmd.createArgument().foo().test().error() >+ .setFile((Name) (destDir()).getAbsoluteFile()); > } > } >\ No newline at end of file >Index: workspace/Formatter/test337/A_out.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/Formatter/test337/A_out.java,v >retrieving revision 1.5 >diff -u -r1.5 A_out.java >--- workspace/Formatter/test337/A_out.java 27 Feb 2006 21:06:52 -0000 1.5 >+++ workspace/Formatter/test337/A_out.java 23 Apr 2010 00:22:04 -0000 >@@ -110,8 +110,8 @@ > } > private IPlatform acquirePlatform() { > if (platformTracker == null) { >- platformTracker = new ServiceTracker(context, IPlatform.class >- .getName(), null); >+ platformTracker = new ServiceTracker(context, >+ IPlatform.class.getName(), null); > platformTracker.open(); > } > IPlatform result = (IPlatform) platformTracker.getService(); >Index: workspace/Formatter/test455/A_out.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/Formatter/test455/A_out.java,v >retrieving revision 1.2 >diff -u -r1.2 A_out.java >--- workspace/Formatter/test455/A_out.java 16 Apr 2004 18:15:46 -0000 1.2 >+++ workspace/Formatter/test455/A_out.java 23 Apr 2010 00:22:04 -0000 >@@ -4,16 +4,14 @@ > try { > IJavaProject javaProject = getJavaProject(configuration); > if ((javaProject == null) || !javaProject.exists()) { >- abort( >- PDEPlugin >- .getResourceString("JUnitLaunchConfiguration.error.invalidproject"), null, IJavaLaunchConfigurationConstants.ERR_NOT_A_JAVA_PROJECT); //$NON-NLS-1$ >+ abort(PDEPlugin >+ .getResourceString("JUnitLaunchConfiguration.error.invalidproject"), null, IJavaLaunchConfigurationConstants.ERR_NOT_A_JAVA_PROJECT); //$NON-NLS-1$ > } > IType[] testTypes = getTestTypes(configuration, javaProject, > new SubProgressMonitor(monitor, 1)); > if (testTypes.length == 0) { >- abort( >- PDEPlugin >- .getResourceString("JUnitLaunchConfiguration.error.notests"), null, IJavaLaunchConfigurationConstants.ERR_UNSPECIFIED_MAIN_TYPE); //$NON-NLS-1$ >+ abort(PDEPlugin >+ .getResourceString("JUnitLaunchConfiguration.error.notests"), null, IJavaLaunchConfigurationConstants.ERR_UNSPECIFIED_MAIN_TYPE); //$NON-NLS-1$ > } > monitor.worked(1); > >@@ -38,8 +36,8 @@ > > setDefaultSourceLocator(launch, configuration); > launch.setAttribute(PORT_ATTR, Integer.toString(port)); >- launch.setAttribute(TESTTYPE_ATTR, testTypes[0] >- .getHandleIdentifier()); >+ launch.setAttribute(TESTTYPE_ATTR, >+ testTypes[0].getHandleIdentifier()); > PDEPlugin.getDefault().getLaunchesListener().manage(launch); > launcher.getVMRunner(mode).run(runnerConfig, launch, monitor); > monitor.worked(1); >Index: workspace/Formatter/test484/A_out.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/Formatter/test484/A_out.java,v >retrieving revision 1.1 >diff -u -r1.1 A_out.java >--- workspace/Formatter/test484/A_out.java 16 Apr 2004 18:15:46 -0000 1.1 >+++ workspace/Formatter/test484/A_out.java 23 Apr 2010 00:22:04 -0000 >@@ -2,9 +2,8 @@ > public void launch() { > try { > if ((javaProject == null) || !javaProject.exists()) { >- abort( >- PDEPlugin >- .getResourceString("JUnitLaunchConfiguration.error.invalidproject"), null, IJavaLaunchConfigurationConstants.ERR_NOT_A_JAVA_PROJECT); //$NON-NLS-1$ >+ abort(PDEPlugin >+ .getResourceString("JUnitLaunchConfiguration.error.invalidproject"), null, IJavaLaunchConfigurationConstants.ERR_NOT_A_JAVA_PROJECT); //$NON-NLS-1$ > } > } catch (CoreException e) { > } >Index: workspace/Formatter/test485/A_out.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/Formatter/test485/A_out.java,v >retrieving revision 1.1 >diff -u -r1.1 A_out.java >--- workspace/Formatter/test485/A_out.java 16 Apr 2004 18:15:46 -0000 1.1 >+++ workspace/Formatter/test485/A_out.java 23 Apr 2010 00:22:04 -0000 >@@ -2,9 +2,8 @@ > public void launch() { > try { > if ((javaProject == null) || !javaProject.exists()) { >- abort( >- PDEPlugin >- .getResourceString("JUnitLaunchConfiguration.error.invalidproject"), >+ abort(PDEPlugin >+ .getResourceString("JUnitLaunchConfiguration.error.invalidproject"), > null, > IJavaLaunchConfigurationConstants.ERR_NOT_A_JAVA_PROJECT); > }
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 59891
: 165868 |
165869
|
166198