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 169154 Details for
Bug 313524
[formatter] Add preference for improved lines wrapping in nested method calls
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
v01.txt (text/plain), 70.24 KB, created by
Frederic Fusier
on 2010-05-19 13:08:13 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2010-05-19 13:08:13 EDT
Size:
70.24 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: buildnotes_jdt-core.html >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/buildnotes_jdt-core.html,v >retrieving revision 1.7461 >diff -u -r1.7461 buildnotes_jdt-core.html >--- buildnotes_jdt-core.html 18 May 2010 18:12:12 -0000 1.7461 >+++ buildnotes_jdt-core.html 19 May 2010 17:01:04 -0000 >@@ -48,6 +48,27 @@ > <br>Project org.eclipse.jdt.core v_A54 > (<a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.core/?only_with_tag=v_A54">cvs</a>). > <h2>What's new in this drop</h2> >+<ul> >+<li> >+Added a new preference to force the formatter to try to keep nested expressions on one line. >+<p> >+This new preference is controlled with the option:</p> >+<code>DefaultCodeFormatterConstants.FORMATTER_KEEP_NESTED_EXPRESSIONS_ON_ONE_LINE</code> >+<pre> >+/** >+ * FORMATTER / Option to try to keep nested expressions on one line >+ * - option id: "org.eclipse.jdt.core.formatter.keep_nested_expressions_on_one_line" >+ * - possible values: { TRUE, FALSE } >+ * - default: FALSE >+ * >+ * @see #TRUE >+ * @see #FALSE >+ * @since 3.6 >+ */ >+</pre> >+See bug <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=313524">313524</a> for more details. >+</li> >+</ul> > > <h3>Problem Reports Fixed</h3> > <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=313109">313109</a> >Index: formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java,v >retrieving revision 1.112 >diff -u -r1.112 DefaultCodeFormatterConstants.java >--- formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java 6 May 2010 11:11:26 -0000 1.112 >+++ formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java 19 May 2010 17:01:09 -0000 >@@ -3500,6 +3500,18 @@ > public static final String FORMATTER_WRAP_BEFORE_BINARY_OPERATOR = JavaCore.PLUGIN_ID + ".formatter.wrap_before_binary_operator"; //$NON-NLS-1$ > /** > * <pre> >+ * FORMATTER / Option to try to keep nested expressions on one line >+ * - option id: "org.eclipse.jdt.core.formatter.keep_nested_expressions_on_one_line" >+ * - possible values: { TRUE, FALSE } >+ * - default: FALSE >+ * </pre> >+ * @see #TRUE >+ * @see #FALSE >+ * @since 3.6 >+ */ >+ public static final String FORMATTER_KEEP_NESTED_EXPRESSIONS_ON_ONE_LINE = JavaCore.PLUGIN_ID + ".formatter.keep_nested_expressions_on_one_line"; //$NON-NLS-1$ >+ /** >+ * <pre> > * FORMATTER / The wrapping is done by indenting by one compare to the current indentation. > * </pre> > * @since 3.0 >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.234 >diff -u -r1.234 CodeFormatterVisitor.java >--- formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java 6 May 2010 16:29:32 -0000 1.234 >+++ formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java 19 May 2010 17:01:16 -0000 >@@ -1364,7 +1364,9 @@ > } > startingPositionInCascade = 2; > } >- int tieBreakRule = size-startingPositionInCascade > 2 ? Alignment.R_OUTERMOST : Alignment.R_INNERMOST; >+ int tieBreakRule = !this.preferences.keep_nested_expression_on_one_line && size-startingPositionInCascade > 2 >+ ? Alignment.R_OUTERMOST >+ : Alignment.R_INNERMOST; > Alignment cascadingMessageSendAlignment = > this.scribe.createAlignment( > Alignment.CASCADING_MESSAGE_SEND, >@@ -1676,7 +1678,7 @@ > Alignment messageAlignment) { > > if (messageAlignment != null) { >- if (messageAlignment.canAlign()) { >+ if (this.preferences.keep_nested_expression_on_one_line || messageAlignment.canAlign()) { > this.scribe.alignFragment(messageAlignment, 0); > } > this.scribe.printNextToken(TerminalTokens.TokenNameDOT); >Index: formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java,v >retrieving revision 1.107 >diff -u -r1.107 DefaultCodeFormatterOptions.java >--- formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java 6 May 2010 11:11:27 -0000 1.107 >+++ formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java 19 May 2010 17:01:22 -0000 >@@ -325,6 +325,7 @@ > public int tab_char; > public boolean use_tabs_only_for_leading_indentations; > public boolean wrap_before_binary_operator; >+ public boolean keep_nested_expression_on_one_line; > > public int initial_indentation_level; > public String line_separator; >@@ -622,6 +623,7 @@ > options.put(DefaultCodeFormatterConstants.FORMATTER_DISABLING_TAG, this.disabling_tag == null ? Util.EMPTY_STRING : new String(this.disabling_tag)); > options.put(DefaultCodeFormatterConstants.FORMATTER_ENABLING_TAG, this.enabling_tag == null ? Util.EMPTY_STRING : new String(this.enabling_tag)); > options.put(DefaultCodeFormatterConstants.FORMATTER_USE_ON_OFF_TAGS, this.use_tags ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE); >+ options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_NESTED_EXPRESSIONS_ON_ONE_LINE, this.keep_nested_expression_on_one_line ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE); > return options; > } > >@@ -1997,6 +1999,10 @@ > } > } > } >+ final Object wrapKeepNestedExpressionsOnOneLineOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_KEEP_NESTED_EXPRESSIONS_ON_ONE_LINE); >+ if (wrapKeepNestedExpressionsOnOneLineOption != null) { >+ this.keep_nested_expression_on_one_line = DefaultCodeFormatterConstants.TRUE.equals(wrapKeepNestedExpressionsOnOneLineOption); >+ } > } > > /** >@@ -2310,6 +2316,7 @@ > this.use_tags = false; > this.disabling_tag = DEFAULT_DISABLING_TAG; > this.enabling_tag = DEFAULT_ENABLING_TAG; >+ this.keep_nested_expression_on_one_line = false; > } > > public void setEclipseDefaultSettings() { >@@ -2584,5 +2591,6 @@ > this.use_tags = false; > this.disabling_tag = DEFAULT_DISABLING_TAG; > this.enabling_tag = DEFAULT_ENABLING_TAG; >+ this.keep_nested_expression_on_one_line = false; > } > } >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.209 >diff -u -r1.209 Scribe.java >--- formatter/org/eclipse/jdt/internal/formatter/Scribe.java 6 May 2010 15:22:52 -0000 1.209 >+++ formatter/org/eclipse/jdt/internal/formatter/Scribe.java 19 May 2010 17:01:27 -0000 >@@ -1258,6 +1258,38 @@ > } > > public void handleLineTooLong() { >+ if (!this.formatter.preferences.keep_nested_expression_on_one_line) { >+ handleLineTooLongSmartly(); >+ return; >+ } >+ // search for closest breakable alignment, using tiebreak rules >+ // look for outermost breakable one >+ int relativeDepth = 0, outerMostDepth = -1; >+ Alignment targetAlignment = this.currentAlignment; >+ while (targetAlignment != null){ >+ if (targetAlignment.tieBreakRule == Alignment.R_OUTERMOST && targetAlignment.couldBreak()){ >+ outerMostDepth = relativeDepth; >+ } >+ targetAlignment = targetAlignment.enclosing; >+ relativeDepth++; >+ } >+ if (outerMostDepth >= 0) { >+ throw new AlignmentException(AlignmentException.LINE_TOO_LONG, outerMostDepth); >+ } >+ // look for innermost breakable one >+ relativeDepth = 0; >+ targetAlignment = this.currentAlignment; >+ while (targetAlignment != null){ >+ if (targetAlignment.couldBreak()){ >+ throw new AlignmentException(AlignmentException.LINE_TOO_LONG, relativeDepth); >+ } >+ targetAlignment = targetAlignment.enclosing; >+ relativeDepth++; >+ } >+ // did not find any breakable location - proceed >+ } >+ >+ private void handleLineTooLongSmartly() { > // search for closest breakable alignment, using tiebreak rules > // look for outermost breakable one > int relativeDepth = 0, outerMostDepth = -1; >#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.30 >diff -u -r1.30 FormatterBugsTests.java >--- src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java 6 May 2010 16:29:35 -0000 1.30 >+++ src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java 19 May 2010 17:01:37 -0000 >@@ -6050,7 +6050,7 @@ > * @test Ensure that the formatter does not take care of formatting tags by default > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=311582" > */ >-public void testBug0311582a() throws JavaModelException { >+public void testBug311582a() throws JavaModelException { > this.formatterPrefs.disabling_tag = "disable-formatter".toCharArray(); > this.formatterPrefs.enabling_tag = "enable-formatter".toCharArray(); > String source = >@@ -6080,7 +6080,7 @@ > "}\n" > ); > } >-public void testBug0311582b() { >+public void testBug311582b() { > this.formatterPrefs = null; > this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_DISABLING_TAG, "off"); > this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_ENABLING_TAG, ""); >@@ -6106,7 +6106,7 @@ > * @test Ensure that the formatter does not take care of formatting tags by default > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=311617" > */ >-public void testBug0311617() throws JavaModelException { >+public void testBug311617() throws JavaModelException { > this.formatterPrefs.use_tags = true; > String source = > "public class X01 {\n" + >@@ -6134,7 +6134,7 @@ > "}\n" > ); > } >-public void testBug0311617b() { >+public void testBug311617b() { > this.formatterPrefs = null; > this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_USE_ON_OFF_TAGS, DefaultCodeFormatterConstants.TRUE); > String source = >@@ -6147,4 +6147,549 @@ > formatSource(source); > } > >+/** >+ * @bug 313524: [formatter] Add preference for improved lines wrapping in nested method calls >+ * @test Ensure that the formatter keep previous eclipse versions behavior when >+ * the "Try to keep nested expressions on one line" preference is set. >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=313524" >+ */ >+public void testBug313524_01() throws JavaModelException { >+ this.formatterPrefs.page_width = 40; >+ this.formatterPrefs.keep_nested_expression_on_one_line = true; >+ 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), bar(5, 6,\n" + >+ " 7, 8));\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug313524_01b() throws JavaModelException { >+ this.formatterPrefs = null; >+ this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "40"); >+ this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_NESTED_EXPRESSIONS_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); >+ 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), bar( 5,\n" + >+ " 6,\n" + >+ " 7,\n" + >+ " 8));\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug313524_02() throws JavaModelException { >+ this.formatterPrefs.page_width = 40; >+ this.formatterPrefs.keep_nested_expression_on_one_line = true; >+ 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), bar(11, 12, 13,\n" + >+ " 14, 15, 16, 17, 18, 19,\n" + >+ " 20));\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug313524_02b() throws JavaModelException { >+ this.formatterPrefs = null; >+ this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "40"); >+ this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_NESTED_EXPRESSIONS_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); >+ 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), bar(11, 12, 13,\n" + >+ " 14, 15, 16,\n" + >+ " 17, 18, 19,\n" + >+ " 20));\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug313524_03() throws JavaModelException { >+ this.formatterPrefs.page_width = 40; >+ this.formatterPrefs.keep_nested_expression_on_one_line = true; >+ 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), bar(5, 6,\n" + >+ " 7, 8), bar(9, 10, 11,\n" + >+ " 12));\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug313524_03b() throws JavaModelException { >+ this.formatterPrefs = null; >+ this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "40"); >+ this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_NESTED_EXPRESSIONS_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); >+ 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), bar( 5,\n" + >+ " 6,\n" + >+ " 7,\n" + >+ " 8),\n" + >+ " bar(9, 10, 11, 12));\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=146175 >+public void testBug313524_146175() throws JavaModelException { >+ this.formatterPrefs.keep_nested_expression_on_one_line = true; >+ 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(instanceOfOtherClass\n" + >+ " .anotherMethod(\"Value of paramter 1\"), instanceOfOtherClass\n" + >+ " .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 testBug313524_164093_01() throws JavaModelException { >+ this.formatterPrefs = null; >+ this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "30"); >+ this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_NESTED_EXPRESSIONS_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); >+ 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 testBug313524_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_KEEP_NESTED_EXPRESSIONS_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); >+ 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 testBug313524_203588() throws JavaModelException { >+ this.formatterPrefs.keep_nested_expression_on_one_line = true; >+ 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, Double.valueOf(allocation.get(idx_ta)\n" + >+ " .doubleValue()\n" + >+ " + q));\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+// wksp1 >+public void testBug313524_wksp1_01() throws JavaModelException { >+ this.formatterPrefs.keep_nested_expression_on_one_line = true; >+ 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(MessageFormat.format(AntDTDSchemaMessages\n" + >+ " .getString(\"NfmParser.Ambiguous\"), new String[] { name })); //$NON-NLS-1$\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug313524_wksp1_02() throws JavaModelException { >+ this.formatterPrefs.keep_nested_expression_on_one_line = true; >+ 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\n" + >+ " .format(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\n" + >+ " .format(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 testBug313524_wksp1_03() throws JavaModelException { >+ this.formatterPrefs.keep_nested_expression_on_one_line = true; >+ 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, InternalAntMessages\n" + >+ " .getString(\"InternalAntRunner.Subtargets__5\"), 0); //$NON-NLS-1$\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug313524_wksp1_04() throws JavaModelException { >+ this.formatterPrefs.keep_nested_expression_on_one_line = true; >+ 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().getBoolean(\n" + >+ " IAntUIPreferenceConstants.OUTLINE_LINK_WITH_EDITOR)) {\n" + >+ " synchronizeOutlinePage(node, true);\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug313524_wksp1_05() throws JavaModelException { >+ this.formatterPrefs.keep_nested_expression_on_one_line = true; >+ 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.getDefault().getPreferenceStore().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 testBug313524_wksp1_06() throws JavaModelException { >+ this.formatterPrefs.keep_nested_expression_on_one_line = true; >+ 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 testBug313524_wksp1_07() throws JavaModelException { >+ this.formatterPrefs.keep_nested_expression_on_one_line = true; >+ 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 testBug313524_wksp1_08() throws JavaModelException { >+ this.formatterPrefs.keep_nested_expression_on_one_line = true; >+ 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\n" + >+ " .format(InternalCoreAntMessages\n" + >+ " .getString(\"AntRunner.Already_in_progess\"), new String[] { buildFileLocation }), null); //$NON-NLS-1$\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug313524_wksp1_09() throws JavaModelException { >+ this.formatterPrefs.keep_nested_expression_on_one_line = true; >+ 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 testBug313524_wksp1_10() throws JavaModelException { >+ this.formatterPrefs.keep_nested_expression_on_one_line = true; >+ 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 testBug313524_wksp1_11() throws JavaModelException { >+ this.formatterPrefs.keep_nested_expression_on_one_line = true; >+ 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(AntLaunchConfigurationMessages\n" + >+ " .getString(\"AntLaunchShortcut.Unable\"), null); //$NON-NLS-1$ \n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug313524_wksp1_12() throws JavaModelException { >+ this.formatterPrefs.keep_nested_expression_on_one_line = true; >+ 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" >+ ); >+} >+ > } >Index: src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java,v >retrieving revision 1.259 >diff -u -r1.259 FormatterRegressionTests.java >--- src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java 2 Mar 2010 18:29:03 -0000 1.259 >+++ src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java 19 May 2010 17:01:56 -0000 >@@ -512,6 +512,13 @@ > runTest("test026", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ > } > >+ public void test026b() { >+ DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); >+ preferences.keep_nested_expression_on_one_line = true; >+ DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); >+ runTest(codeFormatter, "test026b", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ > public void test027() { > runTest("test027", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ > } >@@ -1779,6 +1786,13 @@ > DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); > runTest(codeFormatter, "test167", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ > } >+ public void test167b() { >+ DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); >+ preferences.tab_char = DefaultCodeFormatterOptions.TAB; >+ preferences.keep_nested_expression_on_one_line = true; >+ DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); >+ runTest(codeFormatter, "test167b", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ >+ } > > /** > * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44503 >@@ -1789,6 +1803,13 @@ > DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); > runTest(codeFormatter, "test169", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ > } >+ public void test169b() { >+ DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); >+ preferences.tab_char = DefaultCodeFormatterOptions.TAB; >+ preferences.keep_nested_expression_on_one_line = true; >+ DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); >+ runTest(codeFormatter, "test169b", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ >+ } > > /** > * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44503 >@@ -1799,6 +1820,13 @@ > DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); > runTest(codeFormatter, "test170", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ > } >+ public void test170b() { >+ DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); >+ preferences.tab_char = DefaultCodeFormatterOptions.TAB; >+ preferences.keep_nested_expression_on_one_line = true; >+ DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); >+ runTest(codeFormatter, "test170b", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ >+ } > > /** > * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44576 >@@ -4438,6 +4466,14 @@ > DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); > runTest(codeFormatter, "test337", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ > } >+ public void test337b() { >+ DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); >+ preferences.tab_char = DefaultCodeFormatterOptions.TAB; >+ preferences.number_of_empty_lines_to_preserve = 0; >+ preferences.keep_nested_expression_on_one_line = true; >+ DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); >+ runTest(codeFormatter, "test337b", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ >+ } > > /** > * https://bugs.eclipse.org/bugs/show_bug.cgi?id=46686 >@@ -5980,6 +6016,14 @@ > DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); > runTest(codeFormatter, "test455", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ > } >+ public void test455b() { >+ Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); >+ options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1");//$NON-NLS-1$ >+ options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_NESTED_EXPRESSIONS_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); >+ DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); >+ DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); >+ runTest(codeFormatter, "test455b", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ >+ } > > /** > * https://bugs.eclipse.org/bugs/show_bug.cgi?id=50736 >Index: workspace/Formatter/test026b/A_in.java >=================================================================== >RCS file: workspace/Formatter/test026b/A_in.java >diff -N workspace/Formatter/test026b/A_in.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test026b/A_in.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,8 @@ >+// test026 >+public class A { >+ public void foo() { >+ this.longReceiver.someQuiteLongMessageSend("aaaaaaaaaaa","bbbbbbbbbbbbb","cccccccc"); >+ this.extremlylongReceiverWillCauseTwoSplitActions.someQuiteLongMessageSend("aaaaaaaaaaa","bbbbbbbbbbbbb","cccccccc"); >+ Alignment expressionsAlignment = this.scribe.createAlignment("expressions", Alignment.M_COMPACT_SPLIT + someMessageSend(Alignment.M_COMPACT_SPLIT, Alignment.M_COMPACT_SPLIT, Alignment.M_COMPACT_SPLIT, Alignment.M_COMPACT_SPLIT),expressionsLength - 1, this.scribe.scanner.currentPosition); >+ } >+} >\ No newline at end of file >Index: workspace/Formatter/test026b/A_out.java >=================================================================== >RCS file: workspace/Formatter/test026b/A_out.java >diff -N workspace/Formatter/test026b/A_out.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test026b/A_out.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,17 @@ >+// test026 >+public class A { >+ public void foo() { >+ this.longReceiver.someQuiteLongMessageSend("aaaaaaaaaaa", >+ "bbbbbbbbbbbbb", "cccccccc"); >+ this.extremlylongReceiverWillCauseTwoSplitActions >+ .someQuiteLongMessageSend("aaaaaaaaaaa", "bbbbbbbbbbbbb", >+ "cccccccc"); >+ Alignment expressionsAlignment = this.scribe.createAlignment( >+ "expressions", Alignment.M_COMPACT_SPLIT >+ + someMessageSend(Alignment.M_COMPACT_SPLIT, >+ Alignment.M_COMPACT_SPLIT, >+ Alignment.M_COMPACT_SPLIT, >+ Alignment.M_COMPACT_SPLIT), >+ expressionsLength - 1, this.scribe.scanner.currentPosition); >+ } >+} >\ No newline at end of file >Index: workspace/Formatter/test167b/A_in.java >=================================================================== >RCS file: workspace/Formatter/test167b/A_in.java >diff -N workspace/Formatter/test167b/A_in.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test167b/A_in.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,14 @@ >+public class X { >+ X(String s) { >+ } >+ protected void foo() { >+ X a = new X(new StringBuffer("this").append("is").append >+("a").append( >+ "long") >+ .append("argument") >+ .toString()) { >+ public void run() { >+ } >+ }; >+ } >+} >\ No newline at end of file >Index: workspace/Formatter/test167b/A_out.java >=================================================================== >RCS file: workspace/Formatter/test167b/A_out.java >diff -N workspace/Formatter/test167b/A_out.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test167b/A_out.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,11 @@ >+public class X { >+ X(String s) { >+ } >+ protected void foo() { >+ X a = new X(new StringBuffer("this").append("is").append("a").append( >+ "long").append("argument").toString()) { >+ public void run() { >+ } >+ }; >+ } >+} >\ No newline at end of file >Index: workspace/Formatter/test169b/A_in.java >=================================================================== >RCS file: workspace/Formatter/test169b/A_in.java >diff -N workspace/Formatter/test169b/A_in.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test169b/A_in.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,7 @@ >+public class X { >+ X(String s) { >+ } >+ protected void foo() { >+ cmd.createArgument().foo().test().error().setFile(destDir.getAbsoluteFile()); >+ } >+} >\ No newline at end of file >Index: workspace/Formatter/test169b/A_out.java >=================================================================== >RCS file: workspace/Formatter/test169b/A_out.java >diff -N workspace/Formatter/test169b/A_out.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test169b/A_out.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,8 @@ >+public class X { >+ X(String s) { >+ } >+ protected void foo() { >+ cmd.createArgument().foo().test().error().setFile( >+ destDir.getAbsoluteFile()); >+ } >+} >\ No newline at end of file >Index: workspace/Formatter/test170b/A_in.java >=================================================================== >RCS file: workspace/Formatter/test170b/A_in.java >diff -N workspace/Formatter/test170b/A_in.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test170b/A_in.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,7 @@ >+public class X { >+ X(String s) { >+ } >+ protected void foo() { >+ cmd.createArgument().foo().test().error().setFile((Name) (destDir()).getAbsoluteFile()); >+ } >+} >\ No newline at end of file >Index: workspace/Formatter/test170b/A_out.java >=================================================================== >RCS file: workspace/Formatter/test170b/A_out.java >diff -N workspace/Formatter/test170b/A_out.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test170b/A_out.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,8 @@ >+public class X { >+ X(String s) { >+ } >+ protected void foo() { >+ cmd.createArgument().foo().test().error().setFile( >+ (Name) (destDir()).getAbsoluteFile()); >+ } >+} >\ No newline at end of file >Index: workspace/Formatter/test337b/A_in.java >=================================================================== >RCS file: workspace/Formatter/test337b/A_in.java >diff -N workspace/Formatter/test337b/A_in.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test337b/A_in.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,339 @@ >+package org.eclipse.update.configurator; >+ >+import java.io.File; >+import java.io.IOException; >+import java.net.MalformedURLException; >+import java.net.URL; >+import java.util.*; >+import org.eclipse.core.runtime.*; >+import org.eclipse.osgi.service.environment.DebugOptions; >+import org.eclipse.osgi.service.environment.EnvironmentInfo; >+import org.osgi.framework.*; >+import org.osgi.service.packageadmin.PackageAdmin; >+import org.osgi.service.startlevel.StartLevel; >+import org.osgi.util.tracker.ServiceTracker; >+ >+public class ConfigurationActivator implements BundleActivator { >+ private final static String DEFAULT_CONVERTER = "org.eclipse.update.configurator.migration.PluginConverter"; //$NON-NLS-1$ >+ >+ public static String PI_CONFIGURATOR = "org.eclipse.update.configurator"; >+ // debug options >+ public static String OPTION_DEBUG = PI_CONFIGURATOR + "/debug"; >+ public static String OPTION_DEBUG_CONVERTER = PI_CONFIGURATOR + "/converter/debug"; >+ // debug values >+ public static boolean DEBUG = false; >+ public static boolean DEBUG_CONVERTER = false; >+ >+ private static BundleContext context; >+ private ServiceTracker platformTracker; >+ private ServiceRegistration configurationFactorySR; >+ private String[] allArgs; >+ >+ // location used to put the generated manfests >+ private String cacheLocation = (String) System.getProperties().get("osgi.manifest.cache"); //PASCAL Need to set this value somewhere (probably from boot) >+ private IPluginConverter converter; >+ private Set ignore; >+ private BundleListener reconcilerListener; >+ >+ public void start(BundleContext ctx) throws Exception { >+ context = ctx;loadOptions();if (DEBUG) >+ System.out.println("Starting update configurator..."); >+ computeIgnoredBundles(); >+ loadConverter(); >+ obtainArgs(); >+ installBundles(); >+ } >+ private void computeIgnoredBundles() { >+ String ignoreList = System.getProperty("eclipse.ignore","org.eclipse.osgi,org.eclipse.core.boot,org.eclipse.core.runtime.adaptor"); >+ ignore = new HashSet(); >+ StringTokenizer tokenizer = new StringTokenizer(ignoreList,","); >+ while(tokenizer.hasMoreTokens()) >+ ignore.add(tokenizer.nextToken().trim()); >+ } >+ private boolean shouldIgnore(String bundleName) { >+ if (ignore == null) >+ return false; >+ StringTokenizer tokenizer = new StringTokenizer(bundleName,"._"); >+ String partialName = ""; >+ while(tokenizer.hasMoreTokens()) { >+ partialName += tokenizer.nextToken(); >+ if (ignore.contains(partialName)) >+ return true; >+ partialName += "."; >+ } >+ return false; >+ } >+ private void loadConverter() { >+ // TODO look at making this an extension >+ String converterClassName = System.getProperty("eclipse.manifestconverter", DEFAULT_CONVERTER); >+ if (converterClassName == null) >+ return; >+ Class converterClass; >+ try { >+ converterClass = Class.forName(converterClassName); >+ } catch (ClassNotFoundException e) { >+ return; >+ } >+ try { >+ converter = (IPluginConverter) converterClass.newInstance(); >+ } catch (InstantiationException e1) { >+ return; >+ } catch (IllegalAccessException e1) { >+ return; >+ } catch (ClassCastException cce) { >+ return; >+ } >+ } >+ private void obtainArgs() { >+ // all this is only to get the application args >+ EnvironmentInfo envInfo = null; >+ ServiceReference envInfoSR = context.getServiceReference(EnvironmentInfo.class.getName()); >+ if (envInfoSR != null) >+ envInfo = (EnvironmentInfo) context.getService(envInfoSR); >+ if (envInfo == null) >+ throw new IllegalStateException(); >+ this.allArgs = envInfo.getAllArgs(); >+ // we have what we want - release the service >+ context.ungetService(envInfoSR); >+ } >+ >+ public void stop(BundleContext ctx) throws Exception { >+ releasePlatform(); >+ configurationFactorySR.unregister(); >+ } >+ >+ private void releasePlatform() { >+ if (platformTracker == null) >+ return; >+ platformTracker.close(); >+ platformTracker = null; >+ } >+ private IPlatform acquirePlatform() { >+ if (platformTracker == null) { >+ platformTracker = new ServiceTracker(context, IPlatform.class.getName(), null); >+ platformTracker.open(); >+ } >+ IPlatform result = (IPlatform) platformTracker.getService(); >+ while (result == null) { >+ try { >+ platformTracker.waitForService(1000); >+ result = (IPlatform) platformTracker.getService(); >+ } catch (InterruptedException ie) { >+ } >+ } >+ return result; >+ } >+ >+ private void installBundles() { >+ IPlatform platform = acquirePlatform(); >+ >+ String metaPath = platform.getLocation().append(".metadata").toOSString(); >+ URL installURL = platform.getInstallURL(); >+ ServiceReference reference = context.getServiceReference(StartLevel.class.getName()); >+ StartLevel start = null; >+ if (reference != null) >+ start = (StartLevel) context.getService(reference); >+ try { >+ configurationFactorySR = context.registerService(IPlatformConfigurationFactory.class.getName(), new PlatformConfigurationFactory(), null); >+ PlatformConfiguration config = getPlatformConfiguration(allArgs, metaPath, installURL); >+ URL[] plugins = config.getPluginPath(); >+ ArrayList installed = new ArrayList(plugins.length); >+ for (int i = 0; i < plugins.length; i++) { >+ try { >+ String location = plugins[i].toExternalForm(); >+ checkOrGenerateManifest(location); >+ location = "reference:" + location.substring(0, location.lastIndexOf('/')); >+ if (!isInstalled(location)) { >+ try { >+ Bundle target = context.installBundle(location); >+ installed.add(target); >+ if (start != null) >+ start.setBundleStartLevel(target, 4); >+ } catch (Exception e) { >+ System.err.println("Ignoring bundle at: " + location); >+ System.err.println(e.getMessage()); >+ } >+ } >+ } catch (Exception e) { >+ // TODO Auto-generated catch block >+ e.printStackTrace(); >+ } >+ context.ungetService(reference); >+ refreshPackages((Bundle[]) installed.toArray(new Bundle[installed.size()])); >+ if (System.getProperty("eclipse.application") == null || System.getProperty("eclipse.application").equals(PlatformConfiguration.RECONCILER_APP)) >+ System.setProperty("eclipse.application", config.getApplicationIdentifier()); >+// if (config.getApplicationIdentifier().equals(PlatformConfiguration.RECONCILER_APP) ) { >+// reconcilerListener = reconcilerListener(); >+// context.addBundleListener(reconcilerListener); >+// } >+ } catch (Exception e) { >+ // TODO Auto-generated catch block >+ e.printStackTrace(); >+ } finally { >+ releasePlatform(); >+ } >+ } >+ >+ private BundleListener reconcilerListener() { >+ return new BundleListener() { >+ public void bundleChanged(BundleEvent event) { >+ String buid = event.getBundle().getUniqueId(); >+ if (event.getType() == BundleEvent.STOPPED && buid!=null && buid.equals("org.eclipse.update.core")) >+ runPostReconciler(); >+ } >+ }; >+ } >+ >+ private void runPostReconciler() { >+ Runnable postReconciler = new Runnable() { >+ public void run() { >+ try { >+ Bundle apprunner = context.getBundle("org.eclipse.core.applicationrunner"); >+ apprunner.stop(); >+ context.removeBundleListener(reconcilerListener); >+ try { >+ PlatformConfiguration.shutdown(); >+ } catch (IOException e) { >+ // TODO Auto-generated catch block >+ e.printStackTrace(); >+ } >+ installBundles(); >+ apprunner.start(); >+ } catch (BundleException be) { >+ be.printStackTrace(); >+ } >+ } >+ }; >+ new Thread(postReconciler, "Post reconciler").start(); >+ } >+ /** >+ * @param location >+ */ >+ private void checkOrGenerateManifest(String pluginManifestLocationURL) { >+ if (converter == null) >+ return; >+ String pluginManifestLocation = null; >+ try { >+ pluginManifestLocation = new URL(pluginManifestLocationURL).getPath(); >+ } catch (MalformedURLException e) { >+ return; >+ } >+ File pluginDir = new File(pluginManifestLocation).getParentFile(); >+ if (shouldIgnore(pluginDir.getName())) >+ return; >+ File manifest = new File(pluginDir, "META-INF/MANIFEST.MF"); >+ if (manifest.exists()) >+ return; >+ // bail if the install location is not writable and we don't know where else to write to >+ if (cacheLocation == null) >+ return; >+ File generationLocation = new File(cacheLocation, computeFileName(pluginDir.getPath()) + ".MF"); >+ if (generationLocation.exists()) >+ return; >+ if (!converter.convertManifest(pluginDir, generationLocation)) >+ System.out.println(pluginDir + " manifest generation failed"); >+ } >+ /* >+ * Derives a file name corresponding to a path: >+ * c:\autoexec.bat -> c__autoexec.bat >+ */ >+ private String computeFileName(String filePath) { >+ StringBuffer newName = new StringBuffer(filePath); >+ for (int i = 0; i < filePath.length(); i++) { >+ char c = newName.charAt(i); >+ if (c == ':' || c == '/' || c == '\\') >+ newName.setCharAt(i,'_'); >+ } >+ return newName.toString(); >+ } >+ /** >+ * This is a major hack to try to get the reconciler application running. However we should find a way to not run it. >+ * @param args >+ * @param metaPath >+ * @return >+ */ >+ private PlatformConfiguration getPlatformConfiguration(String[] args, String metaPath, URL installURL) { >+ try { >+ PlatformConfiguration.startup(args, null, null, metaPath, installURL); >+ } catch (Exception e) { >+ if (platformTracker != null) { >+ String message = e.getMessage(); >+ if (message == null) >+ message = ""; >+ IStatus status = new Status(IStatus.ERROR,IPlatform.PI_RUNTIME,IStatus.OK,message,e); >+ ((IPlatform)platformTracker.getService()).getLog(context.getBundle()).log(status); >+ } >+ } >+ return PlatformConfiguration.getCurrent(); >+ >+ } >+ >+ /** >+ * Do PackageAdmin.refreshPackages() in a synchronous way. After installing >+ * all the requested bundles we need to do a refresh and want to ensure that >+ * everything is done before returning. >+ * @param bundles >+ */ >+ private void refreshPackages(Bundle[] bundles) { >+ if (bundles.length == 0) >+ return; >+ ServiceReference packageAdminRef = context.getServiceReference(PackageAdmin.class.getName()); >+ PackageAdmin packageAdmin = null; >+ if (packageAdminRef != null) { >+ packageAdmin = (PackageAdmin) context.getService(packageAdminRef); >+ if (packageAdmin == null) >+ return; >+ } >+ // TODO this is such a hack it is silly. There are still cases for race conditions etc >+ // but this should allow for some progress... >+ final Object semaphore = new Object(); >+ FrameworkListener listener = new FrameworkListener() { >+ public void frameworkEvent(FrameworkEvent event) { >+ if (event.getType() == FrameworkEvent.PACKAGES_REFRESHED) >+ synchronized (semaphore) { >+ semaphore.notifyAll(); >+ } >+ } >+ }; >+ context.addFrameworkListener(listener); >+ packageAdmin.refreshPackages(bundles); >+ synchronized (semaphore) { >+ try { >+ semaphore.wait(); >+ } catch (InterruptedException e) { >+ } >+ } >+ context.removeFrameworkListener(listener); >+ context.ungetService(packageAdminRef); >+ } >+ >+ private boolean isInstalled(String location) { >+ Bundle[] installed = context.getBundles(); >+ for (int i = 0; i < installed.length; i++) { >+ Bundle bundle = installed[i]; >+ if (location.equalsIgnoreCase(bundle.getLocation())) >+ return true; >+ } >+ return false; >+ } >+ >+ private void loadOptions() { >+ // all this is only to get the application args >+ DebugOptions service = null;ServiceReference reference = context.getServiceReference(DebugOptions.class.getName()); >+ if (reference != null) >+ service = (DebugOptions) context.getService(reference); >+ if (service == null) >+ return; >+ try { >+ DEBUG = service.getBooleanOption(OPTION_DEBUG, false); >+ if (!DEBUG) >+ return; >+ DEBUG_CONVERTER = service.getBooleanOption(OPTION_DEBUG_CONVERTER, false); >+ } finally { >+ // we have what we want - release the service >+ context.ungetService(reference); >+ } >+ } >+ public static BundleContext getBundleContext() {return context; >+ } >+} >\ No newline at end of file >Index: workspace/Formatter/test337b/A_out.java >=================================================================== >RCS file: workspace/Formatter/test337b/A_out.java >diff -N workspace/Formatter/test337b/A_out.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test337b/A_out.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,346 @@ >+package org.eclipse.update.configurator; >+import java.io.File; >+import java.io.IOException; >+import java.net.MalformedURLException; >+import java.net.URL; >+import java.util.*; >+import org.eclipse.core.runtime.*; >+import org.eclipse.osgi.service.environment.DebugOptions; >+import org.eclipse.osgi.service.environment.EnvironmentInfo; >+import org.osgi.framework.*; >+import org.osgi.service.packageadmin.PackageAdmin; >+import org.osgi.service.startlevel.StartLevel; >+import org.osgi.util.tracker.ServiceTracker; >+public class ConfigurationActivator implements BundleActivator { >+ private final static String DEFAULT_CONVERTER = "org.eclipse.update.configurator.migration.PluginConverter"; //$NON-NLS-1$ >+ public static String PI_CONFIGURATOR = "org.eclipse.update.configurator"; >+ // debug options >+ public static String OPTION_DEBUG = PI_CONFIGURATOR + "/debug"; >+ public static String OPTION_DEBUG_CONVERTER = PI_CONFIGURATOR >+ + "/converter/debug"; >+ // debug values >+ public static boolean DEBUG = false; >+ public static boolean DEBUG_CONVERTER = false; >+ private static BundleContext context; >+ private ServiceTracker platformTracker; >+ private ServiceRegistration configurationFactorySR; >+ private String[] allArgs; >+ // location used to put the generated manfests >+ private String cacheLocation = (String) System.getProperties().get( >+ "osgi.manifest.cache"); //PASCAL Need to set this value somewhere (probably from boot) >+ private IPluginConverter converter; >+ private Set ignore; >+ private BundleListener reconcilerListener; >+ public void start(BundleContext ctx) throws Exception { >+ context = ctx; >+ loadOptions(); >+ if (DEBUG) >+ System.out.println("Starting update configurator..."); >+ computeIgnoredBundles(); >+ loadConverter(); >+ obtainArgs(); >+ installBundles(); >+ } >+ private void computeIgnoredBundles() { >+ String ignoreList = System >+ .getProperty("eclipse.ignore", >+ "org.eclipse.osgi,org.eclipse.core.boot,org.eclipse.core.runtime.adaptor"); >+ ignore = new HashSet(); >+ StringTokenizer tokenizer = new StringTokenizer(ignoreList, ","); >+ while (tokenizer.hasMoreTokens()) >+ ignore.add(tokenizer.nextToken().trim()); >+ } >+ private boolean shouldIgnore(String bundleName) { >+ if (ignore == null) >+ return false; >+ StringTokenizer tokenizer = new StringTokenizer(bundleName, "._"); >+ String partialName = ""; >+ while (tokenizer.hasMoreTokens()) { >+ partialName += tokenizer.nextToken(); >+ if (ignore.contains(partialName)) >+ return true; >+ partialName += "."; >+ } >+ return false; >+ } >+ private void loadConverter() { >+ // TODO look at making this an extension >+ String converterClassName = System.getProperty( >+ "eclipse.manifestconverter", DEFAULT_CONVERTER); >+ if (converterClassName == null) >+ return; >+ Class converterClass; >+ try { >+ converterClass = Class.forName(converterClassName); >+ } catch (ClassNotFoundException e) { >+ return; >+ } >+ try { >+ converter = (IPluginConverter) converterClass.newInstance(); >+ } catch (InstantiationException e1) { >+ return; >+ } catch (IllegalAccessException e1) { >+ return; >+ } catch (ClassCastException cce) { >+ return; >+ } >+ } >+ private void obtainArgs() { >+ // all this is only to get the application args >+ EnvironmentInfo envInfo = null; >+ ServiceReference envInfoSR = context >+ .getServiceReference(EnvironmentInfo.class.getName()); >+ if (envInfoSR != null) >+ envInfo = (EnvironmentInfo) context.getService(envInfoSR); >+ if (envInfo == null) >+ throw new IllegalStateException(); >+ this.allArgs = envInfo.getAllArgs(); >+ // we have what we want - release the service >+ context.ungetService(envInfoSR); >+ } >+ public void stop(BundleContext ctx) throws Exception { >+ releasePlatform(); >+ configurationFactorySR.unregister(); >+ } >+ private void releasePlatform() { >+ if (platformTracker == null) >+ return; >+ platformTracker.close(); >+ platformTracker = null; >+ } >+ private IPlatform acquirePlatform() { >+ if (platformTracker == null) { >+ platformTracker = new ServiceTracker(context, IPlatform.class >+ .getName(), null); >+ platformTracker.open(); >+ } >+ IPlatform result = (IPlatform) platformTracker.getService(); >+ while (result == null) { >+ try { >+ platformTracker.waitForService(1000); >+ result = (IPlatform) platformTracker.getService(); >+ } catch (InterruptedException ie) { >+ } >+ } >+ return result; >+ } >+ private void installBundles() { >+ IPlatform platform = acquirePlatform(); >+ >+ String metaPath = platform.getLocation().append(".metadata").toOSString(); >+ URL installURL = platform.getInstallURL(); >+ ServiceReference reference = context.getServiceReference(StartLevel.class.getName()); >+ StartLevel start = null; >+ if (reference != null) >+ start = (StartLevel) context.getService(reference); >+ try { >+ configurationFactorySR = context.registerService(IPlatformConfigurationFactory.class.getName(), new PlatformConfigurationFactory(), null); >+ PlatformConfiguration config = getPlatformConfiguration(allArgs, metaPath, installURL); >+ URL[] plugins = config.getPluginPath(); >+ ArrayList installed = new ArrayList(plugins.length); >+ for (int i = 0; i < plugins.length; i++) { >+ try { >+ String location = plugins[i].toExternalForm(); >+ checkOrGenerateManifest(location); >+ location = "reference:" + location.substring(0, location.lastIndexOf('/')); >+ if (!isInstalled(location)) { >+ try { >+ Bundle target = context.installBundle(location); >+ installed.add(target); >+ if (start != null) >+ start.setBundleStartLevel(target, 4); >+ } catch (Exception e) { >+ System.err.println("Ignoring bundle at: " + location); >+ System.err.println(e.getMessage()); >+ } >+ } >+ } catch (Exception e) { >+ // TODO Auto-generated catch block >+ e.printStackTrace(); >+ } >+ context.ungetService(reference); >+ refreshPackages((Bundle[]) installed.toArray(new Bundle[installed.size()])); >+ if (System.getProperty("eclipse.application") == null || System.getProperty("eclipse.application").equals(PlatformConfiguration.RECONCILER_APP)) >+ System.setProperty("eclipse.application", config.getApplicationIdentifier()); >+// if (config.getApplicationIdentifier().equals(PlatformConfiguration.RECONCILER_APP) ) { >+// reconcilerListener = reconcilerListener(); >+// context.addBundleListener(reconcilerListener); >+// } >+ } catch (Exception e) { >+ // TODO Auto-generated catch block >+ e.printStackTrace(); >+ } finally { >+ releasePlatform(); >+ } >+ } >+ private BundleListener reconcilerListener() { >+ return new BundleListener() { >+ public void bundleChanged(BundleEvent event) { >+ String buid = event.getBundle().getUniqueId(); >+ if (event.getType() == BundleEvent.STOPPED && buid != null >+ && buid.equals("org.eclipse.update.core")) >+ runPostReconciler(); >+ } >+ }; >+ } >+ private void runPostReconciler() { >+ Runnable postReconciler = new Runnable() { >+ public void run() { >+ try { >+ Bundle apprunner = context >+ .getBundle("org.eclipse.core.applicationrunner"); >+ apprunner.stop(); >+ context.removeBundleListener(reconcilerListener); >+ try { >+ PlatformConfiguration.shutdown(); >+ } catch (IOException e) { >+ // TODO Auto-generated catch block >+ e.printStackTrace(); >+ } >+ installBundles(); >+ apprunner.start(); >+ } catch (BundleException be) { >+ be.printStackTrace(); >+ } >+ } >+ }; >+ new Thread(postReconciler, "Post reconciler").start(); >+ } >+ /** >+ * @param location >+ */ >+ private void checkOrGenerateManifest(String pluginManifestLocationURL) { >+ if (converter == null) >+ return; >+ String pluginManifestLocation = null; >+ try { >+ pluginManifestLocation = new URL(pluginManifestLocationURL) >+ .getPath(); >+ } catch (MalformedURLException e) { >+ return; >+ } >+ File pluginDir = new File(pluginManifestLocation).getParentFile(); >+ if (shouldIgnore(pluginDir.getName())) >+ return; >+ File manifest = new File(pluginDir, "META-INF/MANIFEST.MF"); >+ if (manifest.exists()) >+ return; >+ // bail if the install location is not writable and we don't know where else to write to >+ if (cacheLocation == null) >+ return; >+ File generationLocation = new File(cacheLocation, >+ computeFileName(pluginDir.getPath()) + ".MF"); >+ if (generationLocation.exists()) >+ return; >+ if (!converter.convertManifest(pluginDir, generationLocation)) >+ System.out.println(pluginDir + " manifest generation failed"); >+ } >+ /* >+ * Derives a file name corresponding to a path: >+ * c:\autoexec.bat -> c__autoexec.bat >+ */ >+ private String computeFileName(String filePath) { >+ StringBuffer newName = new StringBuffer(filePath); >+ for (int i = 0; i < filePath.length(); i++) { >+ char c = newName.charAt(i); >+ if (c == ':' || c == '/' || c == '\\') >+ newName.setCharAt(i, '_'); >+ } >+ return newName.toString(); >+ } >+ /** >+ * This is a major hack to try to get the reconciler application running. However we should find a way to not run it. >+ * @param args >+ * @param metaPath >+ * @return >+ */ >+ private PlatformConfiguration getPlatformConfiguration(String[] args, >+ String metaPath, URL installURL) { >+ try { >+ PlatformConfiguration.startup(args, null, null, metaPath, >+ installURL); >+ } catch (Exception e) { >+ if (platformTracker != null) { >+ String message = e.getMessage(); >+ if (message == null) >+ message = ""; >+ IStatus status = new Status(IStatus.ERROR, >+ IPlatform.PI_RUNTIME, IStatus.OK, message, e); >+ ((IPlatform) platformTracker.getService()).getLog( >+ context.getBundle()).log(status); >+ } >+ } >+ return PlatformConfiguration.getCurrent(); >+ } >+ /** >+ * Do PackageAdmin.refreshPackages() in a synchronous way. After installing >+ * all the requested bundles we need to do a refresh and want to ensure that >+ * everything is done before returning. >+ * @param bundles >+ */ >+ private void refreshPackages(Bundle[] bundles) { >+ if (bundles.length == 0) >+ return; >+ ServiceReference packageAdminRef = context >+ .getServiceReference(PackageAdmin.class.getName()); >+ PackageAdmin packageAdmin = null; >+ if (packageAdminRef != null) { >+ packageAdmin = (PackageAdmin) context.getService(packageAdminRef); >+ if (packageAdmin == null) >+ return; >+ } >+ // TODO this is such a hack it is silly. There are still cases for race conditions etc >+ // but this should allow for some progress... >+ final Object semaphore = new Object(); >+ FrameworkListener listener = new FrameworkListener() { >+ public void frameworkEvent(FrameworkEvent event) { >+ if (event.getType() == FrameworkEvent.PACKAGES_REFRESHED) >+ synchronized (semaphore) { >+ semaphore.notifyAll(); >+ } >+ } >+ }; >+ context.addFrameworkListener(listener); >+ packageAdmin.refreshPackages(bundles); >+ synchronized (semaphore) { >+ try { >+ semaphore.wait(); >+ } catch (InterruptedException e) { >+ } >+ } >+ context.removeFrameworkListener(listener); >+ context.ungetService(packageAdminRef); >+ } >+ private boolean isInstalled(String location) { >+ Bundle[] installed = context.getBundles(); >+ for (int i = 0; i < installed.length; i++) { >+ Bundle bundle = installed[i]; >+ if (location.equalsIgnoreCase(bundle.getLocation())) >+ return true; >+ } >+ return false; >+ } >+ private void loadOptions() { >+ // all this is only to get the application args >+ DebugOptions service = null; >+ ServiceReference reference = context >+ .getServiceReference(DebugOptions.class.getName()); >+ if (reference != null) >+ service = (DebugOptions) context.getService(reference); >+ if (service == null) >+ return; >+ try { >+ DEBUG = service.getBooleanOption(OPTION_DEBUG, false); >+ if (!DEBUG) >+ return; >+ DEBUG_CONVERTER = service.getBooleanOption(OPTION_DEBUG_CONVERTER, >+ false); >+ } finally { >+ // we have what we want - release the service >+ context.ungetService(reference); >+ } >+ } >+ public static BundleContext getBundleContext() { >+ return context; >+ } >+} >\ No newline at end of file >Index: workspace/Formatter/test455b/A_in.java >=================================================================== >RCS file: workspace/Formatter/test455b/A_in.java >diff -N workspace/Formatter/test455b/A_in.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test455b/A_in.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,49 @@ >+public class A { >+ public void launch( >+ ILaunchConfiguration configuration, >+ String mode, >+ ILaunch launch, >+ IProgressMonitor monitor) >+ throws CoreException { >+ 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$ >+ } >+ 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$ >+ } >+ monitor.worked(1); >+ >+ IVMInstall launcher = LauncherUtils.createLauncher(configuration); >+ monitor.worked(1); >+ >+ int port = SocketUtil.findFreePort(); >+ VMRunnerConfiguration runnerConfig = >+ createVMRunner(configuration, testTypes, port, mode); >+ if (runnerConfig == null) { >+ monitor.setCanceled(true); >+ return; >+ } >+ monitor.worked(1); >+ >+ launch.setAttribute( >+ ILauncherSettings.CONFIG_LOCATION, >+ (configFile == null) ? null : configFile.getParent()); >+ >+ String workspace = configuration.getAttribute(LOCATION + "0", getDefaultWorkspace(configuration)); >+ LauncherUtils.clearWorkspace(configuration,workspace); >+ >+ setDefaultSourceLocator(launch, configuration); >+ launch.setAttribute(PORT_ATTR, Integer.toString(port)); >+ launch.setAttribute(TESTTYPE_ATTR, testTypes[0].getHandleIdentifier()); >+ PDEPlugin.getDefault().getLaunchesListener().manage(launch); >+ launcher.getVMRunner(mode).run(runnerConfig, launch, monitor); >+ monitor.worked(1); >+ } catch (CoreException e) { >+ monitor.setCanceled(true); >+ throw e; >+ } >+ } >+} >\ No newline at end of file >Index: workspace/Formatter/test455b/A_out.java >=================================================================== >RCS file: workspace/Formatter/test455b/A_out.java >diff -N workspace/Formatter/test455b/A_out.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test455b/A_out.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,49 @@ >+public class A { >+ public void launch(ILaunchConfiguration configuration, String mode, >+ ILaunch launch, IProgressMonitor monitor) throws CoreException { >+ 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$ >+ } >+ 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$ >+ } >+ monitor.worked(1); >+ >+ IVMInstall launcher = LauncherUtils.createLauncher(configuration); >+ monitor.worked(1); >+ >+ int port = SocketUtil.findFreePort(); >+ VMRunnerConfiguration runnerConfig = createVMRunner(configuration, >+ testTypes, port, mode); >+ if (runnerConfig == null) { >+ monitor.setCanceled(true); >+ return; >+ } >+ monitor.worked(1); >+ >+ launch.setAttribute(ILauncherSettings.CONFIG_LOCATION, >+ (configFile == null) ? null : configFile.getParent()); >+ >+ String workspace = configuration.getAttribute(LOCATION + "0", >+ getDefaultWorkspace(configuration)); >+ LauncherUtils.clearWorkspace(configuration, workspace); >+ >+ setDefaultSourceLocator(launch, configuration); >+ launch.setAttribute(PORT_ATTR, Integer.toString(port)); >+ launch.setAttribute(TESTTYPE_ATTR, testTypes[0] >+ .getHandleIdentifier()); >+ PDEPlugin.getDefault().getLaunchesListener().manage(launch); >+ launcher.getVMRunner(mode).run(runnerConfig, launch, monitor); >+ monitor.worked(1); >+ } catch (CoreException e) { >+ monitor.setCanceled(true); >+ throw e; >+ } >+ } >+} >\ No newline at end of file
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 313524
:
169154
|
169285
|
169295
|
169296