From 0c7100e36708546da79587588602cca2966098d6 Mon Sep 17 00:00:00 2001 From: Hannes Wellmann Date: Wed, 29 Nov 2023 00:00:36 +0100 Subject: [PATCH] Re-normalize line-endings in git of all files to Linux style ("\n") Some files were checked-in into git having windows style line endings (\r\n). This is in general not wanted because it can cause modified files without any difference in git-staging on Windows if auto-crlf is enabled. To re-normalize line endings of all files use the following command (including dot): git add --renormalize . --- .../src/java/io/Serializable.java | 8 +- .../src/java/lang/CharSequence.java | 10 +- .../src/java/lang/Class.java | 8 +- .../java/lang/CloneNotSupportedException.java | 8 +- .../src/java/lang/Comparable.java | 8 +- .../src/java/lang/Deprecated.java | 10 +- JCL/converterJclMin15/src/java/lang/Enum.java | 34 +- .../src/java/lang/Error.java | 32 +- .../src/java/lang/Exception.java | 38 +- .../src/java/lang/IllegalAccessException.java | 10 +- .../lang/IllegalMonitorStateException.java | 8 +- .../src/java/lang/InterruptedException.java | 8 +- .../src/java/lang/NoSuchMethodException.java | 10 +- .../src/java/lang/Object.java | 68 +- .../src/java/lang/RuntimeException.java | 24 +- .../src/java/lang/String.java | 16 +- .../src/java/lang/Throwable.java | 40 +- .../src/java/lang/annotation/Annotation.java | 8 +- .../src/java/lang/annotation/Documented.java | 14 +- .../src/java/lang/annotation/Inherited.java | 12 +- .../src/java/lang/annotation/Retention.java | 14 +- .../java/lang/annotation/RetentionPolicy.java | 10 +- .../src/java/lang/annotation/Target.java | 14 +- .../src/java/lang/invoke/MethodHandle.java | 74 +- .../src/java/lang/invoke/MethodHandles.java | 42 +- .../src/java/lang/invoke/MethodType.java | 34 +- .../src/java/util/Collection.java | 18 +- .../src/java/util/Iterator.java | 14 +- JCL/converterJclMin15/src/java/util/List.java | 8 +- JCL/converterJclMin15/src/java/util/Map.java | 8 +- .../src/java/io/Serializable.java | 8 +- .../src/java/lang/CharSequence.java | 10 +- .../src/java/lang/Class.java | 8 +- .../java/lang/CloneNotSupportedException.java | 8 +- .../src/java/lang/Comparable.java | 8 +- .../src/java/lang/Deprecated.java | 10 +- JCL/converterJclMin17/src/java/lang/Enum.java | 36 +- .../src/java/lang/Error.java | 32 +- .../src/java/lang/Exception.java | 38 +- .../src/java/lang/IllegalAccessException.java | 10 +- .../lang/IllegalMonitorStateException.java | 8 +- .../src/java/lang/InterruptedException.java | 8 +- .../src/java/lang/NoSuchMethodException.java | 10 +- .../src/java/lang/Object.java | 68 +- .../src/java/lang/RuntimeException.java | 24 +- .../src/java/lang/String.java | 16 +- .../src/java/lang/Throwable.java | 40 +- .../src/java/lang/annotation/Annotation.java | 8 +- .../src/java/lang/annotation/Documented.java | 24 +- .../src/java/lang/annotation/Inherited.java | 24 +- .../src/java/lang/annotation/Retention.java | 26 +- .../java/lang/annotation/RetentionPolicy.java | 10 +- .../src/java/lang/annotation/Target.java | 26 +- .../src/java/lang/invoke/MethodHandle.java | 76 +- .../src/java/lang/invoke/MethodHandles.java | 44 +- .../src/java/lang/invoke/MethodType.java | 34 +- .../src/java/util/Collection.java | 18 +- .../src/java/util/Iterator.java | 14 +- JCL/converterJclMin17/src/java/util/List.java | 8 +- JCL/converterJclMin17/src/java/util/Map.java | 8 +- .../src/java/io/Serializable.java | 8 +- .../src/java/lang/CharSequence.java | 10 +- .../src/java/lang/Class.java | 8 +- .../java/lang/CloneNotSupportedException.java | 8 +- .../src/java/lang/Comparable.java | 8 +- .../src/java/lang/Deprecated.java | 10 +- JCL/converterJclMin18/src/java/lang/Enum.java | 36 +- .../src/java/lang/Error.java | 32 +- .../src/java/lang/Exception.java | 38 +- .../src/java/lang/IllegalAccessException.java | 10 +- .../lang/IllegalMonitorStateException.java | 8 +- .../src/java/lang/InterruptedException.java | 8 +- .../src/java/lang/NoSuchMethodException.java | 10 +- .../src/java/lang/Object.java | 68 +- .../src/java/lang/RuntimeException.java | 24 +- .../src/java/lang/String.java | 16 +- .../src/java/lang/Throwable.java | 40 +- .../src/java/lang/annotation/Annotation.java | 8 +- .../src/java/lang/annotation/Documented.java | 24 +- .../src/java/lang/annotation/Inherited.java | 24 +- .../src/java/lang/annotation/Retention.java | 26 +- .../java/lang/annotation/RetentionPolicy.java | 10 +- .../src/java/lang/annotation/Target.java | 26 +- .../src/java/lang/invoke/MethodHandle.java | 76 +- .../src/java/lang/invoke/MethodHandles.java | 44 +- .../src/java/lang/invoke/MethodType.java | 34 +- .../src/java/util/Collection.java | 18 +- .../src/java/util/Iterator.java | 14 +- JCL/converterJclMin18/src/java/util/List.java | 8 +- JCL/converterJclMin18/src/java/util/Map.java | 8 +- .../src/java/io/Serializable.java | 8 +- .../src/java/lang/CharSequence.java | 10 +- .../src/java/lang/Class.java | 8 +- .../java/lang/CloneNotSupportedException.java | 8 +- .../src/java/lang/Comparable.java | 8 +- .../src/java/lang/Deprecated.java | 10 +- JCL/converterJclMin19/src/java/lang/Enum.java | 36 +- .../src/java/lang/Error.java | 32 +- .../src/java/lang/Exception.java | 38 +- .../src/java/lang/IllegalAccessException.java | 10 +- .../lang/IllegalMonitorStateException.java | 8 +- .../src/java/lang/InterruptedException.java | 8 +- .../src/java/lang/NoSuchMethodException.java | 10 +- .../src/java/lang/Object.java | 68 +- .../src/java/lang/RuntimeException.java | 24 +- .../src/java/lang/String.java | 16 +- .../src/java/lang/Throwable.java | 40 +- .../src/java/lang/annotation/Annotation.java | 8 +- .../src/java/lang/annotation/Documented.java | 24 +- .../src/java/lang/annotation/Inherited.java | 24 +- .../src/java/lang/annotation/Retention.java | 26 +- .../java/lang/annotation/RetentionPolicy.java | 10 +- .../src/java/lang/annotation/Target.java | 26 +- .../src/java/lang/invoke/MethodHandle.java | 76 +- .../src/java/lang/invoke/MethodHandles.java | 44 +- .../src/java/lang/invoke/MethodType.java | 34 +- .../src/java/util/Collection.java | 18 +- .../src/java/util/Iterator.java | 14 +- JCL/converterJclMin19/src/java/util/List.java | 8 +- JCL/converterJclMin19/src/java/util/Map.java | 8 +- .../compiler/regression/Deprecated18Test.java | 6 +- .../regression/SwitchPatternTest.java | 6 +- .../formatter/FormatterRegressionTests.java | 32524 ++++++++-------- .../tests/model/JavaSearchBugsTests2.java | 6224 +-- .../core/tests/model/ResolveTests12To15.java | 4 +- .../jdt/internal/compiler/parser/parser19.rsc | 2 +- .../JavaSearchBugs/src/b573388/C.java | 8 +- .../JavaSearchBugs/src/b573388/R.java | 8 +- .../JavaSearchBugs/src/b573388/X.java | 16 +- 129 files changed, 20697 insertions(+), 20697 deletions(-) diff --git a/JCL/converterJclMin15/src/java/io/Serializable.java b/JCL/converterJclMin15/src/java/io/Serializable.java index edd882d7d58..3629567396a 100644 --- a/JCL/converterJclMin15/src/java/io/Serializable.java +++ b/JCL/converterJclMin15/src/java/io/Serializable.java @@ -1,4 +1,4 @@ -package java.io; - -public interface Serializable { -} +package java.io; + +public interface Serializable { +} diff --git a/JCL/converterJclMin15/src/java/lang/CharSequence.java b/JCL/converterJclMin15/src/java/lang/CharSequence.java index b9a0d9e4176..b03fc9e823b 100644 --- a/JCL/converterJclMin15/src/java/lang/CharSequence.java +++ b/JCL/converterJclMin15/src/java/lang/CharSequence.java @@ -1,5 +1,5 @@ -package java.lang; - -public interface CharSequence { - int length(); -} +package java.lang; + +public interface CharSequence { + int length(); +} diff --git a/JCL/converterJclMin15/src/java/lang/Class.java b/JCL/converterJclMin15/src/java/lang/Class.java index a7667b98347..7d08bf1f389 100644 --- a/JCL/converterJclMin15/src/java/lang/Class.java +++ b/JCL/converterJclMin15/src/java/lang/Class.java @@ -1,4 +1,4 @@ -package java.lang; - -public class Class { -} +package java.lang; + +public class Class { +} diff --git a/JCL/converterJclMin15/src/java/lang/CloneNotSupportedException.java b/JCL/converterJclMin15/src/java/lang/CloneNotSupportedException.java index cb777dc7bac..6f05a932fab 100644 --- a/JCL/converterJclMin15/src/java/lang/CloneNotSupportedException.java +++ b/JCL/converterJclMin15/src/java/lang/CloneNotSupportedException.java @@ -1,4 +1,4 @@ -package java.lang; - -public class CloneNotSupportedException extends Exception { -} +package java.lang; + +public class CloneNotSupportedException extends Exception { +} diff --git a/JCL/converterJclMin15/src/java/lang/Comparable.java b/JCL/converterJclMin15/src/java/lang/Comparable.java index fbc6c8bac34..59fb9eddd47 100644 --- a/JCL/converterJclMin15/src/java/lang/Comparable.java +++ b/JCL/converterJclMin15/src/java/lang/Comparable.java @@ -1,4 +1,4 @@ -package java.lang; - -public interface Comparable { -} +package java.lang; + +public interface Comparable { +} diff --git a/JCL/converterJclMin15/src/java/lang/Deprecated.java b/JCL/converterJclMin15/src/java/lang/Deprecated.java index 6c73dedd0d1..5226e586c7e 100644 --- a/JCL/converterJclMin15/src/java/lang/Deprecated.java +++ b/JCL/converterJclMin15/src/java/lang/Deprecated.java @@ -1,6 +1,6 @@ -package java.lang; -import java.lang.annotation.*; -@Documented -@Retention(RetentionPolicy.RUNTIME) -public @interface Deprecated { +package java.lang; +import java.lang.annotation.*; +@Documented +@Retention(RetentionPolicy.RUNTIME) +public @interface Deprecated { } \ No newline at end of file diff --git a/JCL/converterJclMin15/src/java/lang/Enum.java b/JCL/converterJclMin15/src/java/lang/Enum.java index d2ab8443159..f5761fb3189 100644 --- a/JCL/converterJclMin15/src/java/lang/Enum.java +++ b/JCL/converterJclMin15/src/java/lang/Enum.java @@ -1,18 +1,18 @@ -package java.lang; - -public abstract class Enum> implements Comparable, java.io.Serializable { - private static final long serialVersionUID = 2L; - - protected Enum(String name, int ordinal) { - } - public final String name() { - return null; - } - public final int ordinal() { - return 0; - } - public static > T valueOf(Class enumClass, - String name) { - return null; - } +package java.lang; + +public abstract class Enum> implements Comparable, java.io.Serializable { + private static final long serialVersionUID = 2L; + + protected Enum(String name, int ordinal) { + } + public final String name() { + return null; + } + public final int ordinal() { + return 0; + } + public static > T valueOf(Class enumClass, + String name) { + return null; + } } \ No newline at end of file diff --git a/JCL/converterJclMin15/src/java/lang/Error.java b/JCL/converterJclMin15/src/java/lang/Error.java index 9a446d53249..820d8c62226 100644 --- a/JCL/converterJclMin15/src/java/lang/Error.java +++ b/JCL/converterJclMin15/src/java/lang/Error.java @@ -1,16 +1,16 @@ -package java.lang; - -public class Error extends Throwable { - - public Error(java.lang.String s) { - // TODO Auto-generated constructor stub - } - - public Error(java.lang.String s, java.lang.Throwable cause) { - // TODO Auto-generated constructor stub - } - - public Error() { - // TODO Auto-generated constructor stub - } -} +package java.lang; + +public class Error extends Throwable { + + public Error(java.lang.String s) { + // TODO Auto-generated constructor stub + } + + public Error(java.lang.String s, java.lang.Throwable cause) { + // TODO Auto-generated constructor stub + } + + public Error() { + // TODO Auto-generated constructor stub + } +} diff --git a/JCL/converterJclMin15/src/java/lang/Exception.java b/JCL/converterJclMin15/src/java/lang/Exception.java index 0adef36baff..88b222a9c06 100644 --- a/JCL/converterJclMin15/src/java/lang/Exception.java +++ b/JCL/converterJclMin15/src/java/lang/Exception.java @@ -1,19 +1,19 @@ -package java.lang; - -public class Exception extends Throwable { - public Exception() { - super(); - } - - public Exception(String message) { - super(message); - } - - public Exception(String message, Throwable cause) { - super(message, cause); - } - - public Exception(Throwable cause) { - super(cause); - } -} +package java.lang; + +public class Exception extends Throwable { + public Exception() { + super(); + } + + public Exception(String message) { + super(message); + } + + public Exception(String message, Throwable cause) { + super(message, cause); + } + + public Exception(Throwable cause) { + super(cause); + } +} diff --git a/JCL/converterJclMin15/src/java/lang/IllegalAccessException.java b/JCL/converterJclMin15/src/java/lang/IllegalAccessException.java index 814649067f6..0d13e1e0571 100644 --- a/JCL/converterJclMin15/src/java/lang/IllegalAccessException.java +++ b/JCL/converterJclMin15/src/java/lang/IllegalAccessException.java @@ -1,5 +1,5 @@ -package java.lang; - -public class IllegalAccessException extends RuntimeException { - -} +package java.lang; + +public class IllegalAccessException extends RuntimeException { + +} diff --git a/JCL/converterJclMin15/src/java/lang/IllegalMonitorStateException.java b/JCL/converterJclMin15/src/java/lang/IllegalMonitorStateException.java index e173f133abe..1f67418128c 100644 --- a/JCL/converterJclMin15/src/java/lang/IllegalMonitorStateException.java +++ b/JCL/converterJclMin15/src/java/lang/IllegalMonitorStateException.java @@ -1,4 +1,4 @@ -package java.lang; - -public class IllegalMonitorStateException extends RuntimeException { -} +package java.lang; + +public class IllegalMonitorStateException extends RuntimeException { +} diff --git a/JCL/converterJclMin15/src/java/lang/InterruptedException.java b/JCL/converterJclMin15/src/java/lang/InterruptedException.java index e2e84ba0bc2..93b236c4210 100644 --- a/JCL/converterJclMin15/src/java/lang/InterruptedException.java +++ b/JCL/converterJclMin15/src/java/lang/InterruptedException.java @@ -1,4 +1,4 @@ -package java.lang; - -public class InterruptedException extends Exception { -} +package java.lang; + +public class InterruptedException extends Exception { +} diff --git a/JCL/converterJclMin15/src/java/lang/NoSuchMethodException.java b/JCL/converterJclMin15/src/java/lang/NoSuchMethodException.java index b8c5bce7a5b..3dd142bdd33 100644 --- a/JCL/converterJclMin15/src/java/lang/NoSuchMethodException.java +++ b/JCL/converterJclMin15/src/java/lang/NoSuchMethodException.java @@ -1,5 +1,5 @@ -package java.lang; - -public class NoSuchMethodException extends RuntimeException { - -} +package java.lang; + +public class NoSuchMethodException extends RuntimeException { + +} diff --git a/JCL/converterJclMin15/src/java/lang/Object.java b/JCL/converterJclMin15/src/java/lang/Object.java index eb50899e5ba..71ddb4ff834 100644 --- a/JCL/converterJclMin15/src/java/lang/Object.java +++ b/JCL/converterJclMin15/src/java/lang/Object.java @@ -1,34 +1,34 @@ -package java.lang; - -public class Object { - -public Object() { -} -protected Object clone() throws CloneNotSupportedException { - return null; -} -public boolean equals (Object obj) { - return false; -} -protected void finalize () throws Throwable { -} -public final Class getClass() { - return null; -} -public int hashCode() { - return -1; -} -public final void notify() throws IllegalMonitorStateException { -} -public final void notifyAll() throws IllegalMonitorStateException { -} -public String toString () { - return null; -} -public final void wait () throws IllegalMonitorStateException, InterruptedException { -} -public final void wait (long millis) throws IllegalMonitorStateException, InterruptedException { -} -public final void wait (long millis, int nanos) throws IllegalMonitorStateException, InterruptedException { -} -} +package java.lang; + +public class Object { + +public Object() { +} +protected Object clone() throws CloneNotSupportedException { + return null; +} +public boolean equals (Object obj) { + return false; +} +protected void finalize () throws Throwable { +} +public final Class getClass() { + return null; +} +public int hashCode() { + return -1; +} +public final void notify() throws IllegalMonitorStateException { +} +public final void notifyAll() throws IllegalMonitorStateException { +} +public String toString () { + return null; +} +public final void wait () throws IllegalMonitorStateException, InterruptedException { +} +public final void wait (long millis) throws IllegalMonitorStateException, InterruptedException { +} +public final void wait (long millis, int nanos) throws IllegalMonitorStateException, InterruptedException { +} +} diff --git a/JCL/converterJclMin15/src/java/lang/RuntimeException.java b/JCL/converterJclMin15/src/java/lang/RuntimeException.java index 80dc1dbd34e..3d94712d7f8 100644 --- a/JCL/converterJclMin15/src/java/lang/RuntimeException.java +++ b/JCL/converterJclMin15/src/java/lang/RuntimeException.java @@ -1,12 +1,12 @@ -package java.lang; - -public class RuntimeException extends Exception { - - public RuntimeException(java.lang.String s) { - // TODO Auto-generated constructor stub - } - - public RuntimeException() { - // TODO Auto-generated constructor stub - } -} +package java.lang; + +public class RuntimeException extends Exception { + + public RuntimeException(java.lang.String s) { + // TODO Auto-generated constructor stub + } + + public RuntimeException() { + // TODO Auto-generated constructor stub + } +} diff --git a/JCL/converterJclMin15/src/java/lang/String.java b/JCL/converterJclMin15/src/java/lang/String.java index ba6bf08bf4f..64f759b78be 100644 --- a/JCL/converterJclMin15/src/java/lang/String.java +++ b/JCL/converterJclMin15/src/java/lang/String.java @@ -1,8 +1,8 @@ -package java.lang; - -public class String implements CharSequence { - public int length() { return 0; } - public int codePointAt(int index) { - return 0; - } -} +package java.lang; + +public class String implements CharSequence { + public int length() { return 0; } + public int codePointAt(int index) { + return 0; + } +} diff --git a/JCL/converterJclMin15/src/java/lang/Throwable.java b/JCL/converterJclMin15/src/java/lang/Throwable.java index 2488269bebc..73ab84b6950 100644 --- a/JCL/converterJclMin15/src/java/lang/Throwable.java +++ b/JCL/converterJclMin15/src/java/lang/Throwable.java @@ -1,20 +1,20 @@ -package java.lang; - -public class Throwable { - - public Throwable(java.lang.String message) { - // TODO Auto-generated constructor stub - } - - public Throwable() { - // TODO Auto-generated constructor stub - } - - public Throwable(java.lang.String message, Throwable cause) { - // TODO Auto-generated constructor stub - } - - public Throwable(Throwable cause) { - // TODO Auto-generated constructor stub - } -} +package java.lang; + +public class Throwable { + + public Throwable(java.lang.String message) { + // TODO Auto-generated constructor stub + } + + public Throwable() { + // TODO Auto-generated constructor stub + } + + public Throwable(java.lang.String message, Throwable cause) { + // TODO Auto-generated constructor stub + } + + public Throwable(Throwable cause) { + // TODO Auto-generated constructor stub + } +} diff --git a/JCL/converterJclMin15/src/java/lang/annotation/Annotation.java b/JCL/converterJclMin15/src/java/lang/annotation/Annotation.java index ba72aad15ec..530c272ea43 100644 --- a/JCL/converterJclMin15/src/java/lang/annotation/Annotation.java +++ b/JCL/converterJclMin15/src/java/lang/annotation/Annotation.java @@ -1,4 +1,4 @@ -package java.lang.annotation; -public interface Annotation { - -} +package java.lang.annotation; +public interface Annotation { + +} diff --git a/JCL/converterJclMin15/src/java/lang/annotation/Documented.java b/JCL/converterJclMin15/src/java/lang/annotation/Documented.java index 4342263d2df..840d0f454e9 100644 --- a/JCL/converterJclMin15/src/java/lang/annotation/Documented.java +++ b/JCL/converterJclMin15/src/java/lang/annotation/Documented.java @@ -1,7 +1,7 @@ -package java.lang.annotation; - -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface Documented { -} +package java.lang.annotation; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.ANNOTATION_TYPE) +public @interface Documented { +} diff --git a/JCL/converterJclMin15/src/java/lang/annotation/Inherited.java b/JCL/converterJclMin15/src/java/lang/annotation/Inherited.java index 1db265bcd42..ed69c0b04e4 100644 --- a/JCL/converterJclMin15/src/java/lang/annotation/Inherited.java +++ b/JCL/converterJclMin15/src/java/lang/annotation/Inherited.java @@ -1,7 +1,7 @@ -package java.lang.annotation; - -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface Inherited { +package java.lang.annotation; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.ANNOTATION_TYPE) +public @interface Inherited { } \ No newline at end of file diff --git a/JCL/converterJclMin15/src/java/lang/annotation/Retention.java b/JCL/converterJclMin15/src/java/lang/annotation/Retention.java index d52a861d55d..25e8ba73963 100644 --- a/JCL/converterJclMin15/src/java/lang/annotation/Retention.java +++ b/JCL/converterJclMin15/src/java/lang/annotation/Retention.java @@ -1,8 +1,8 @@ -package java.lang.annotation; - -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface Retention { - RetentionPolicy value(); +package java.lang.annotation; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.ANNOTATION_TYPE) +public @interface Retention { + RetentionPolicy value(); } \ No newline at end of file diff --git a/JCL/converterJclMin15/src/java/lang/annotation/RetentionPolicy.java b/JCL/converterJclMin15/src/java/lang/annotation/RetentionPolicy.java index b69fa7d6544..26349b19198 100644 --- a/JCL/converterJclMin15/src/java/lang/annotation/RetentionPolicy.java +++ b/JCL/converterJclMin15/src/java/lang/annotation/RetentionPolicy.java @@ -1,6 +1,6 @@ -package java.lang.annotation; -public enum RetentionPolicy { - CLASS, - SOURCE, - RUNTIME +package java.lang.annotation; +public enum RetentionPolicy { + CLASS, + SOURCE, + RUNTIME } \ No newline at end of file diff --git a/JCL/converterJclMin15/src/java/lang/annotation/Target.java b/JCL/converterJclMin15/src/java/lang/annotation/Target.java index 8ad7f0f21f7..3ee9c31f48a 100644 --- a/JCL/converterJclMin15/src/java/lang/annotation/Target.java +++ b/JCL/converterJclMin15/src/java/lang/annotation/Target.java @@ -1,8 +1,8 @@ -package java.lang.annotation; - -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface Target { - ElementType[] value(); +package java.lang.annotation; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.ANNOTATION_TYPE) +public @interface Target { + ElementType[] value(); } \ No newline at end of file diff --git a/JCL/converterJclMin15/src/java/lang/invoke/MethodHandle.java b/JCL/converterJclMin15/src/java/lang/invoke/MethodHandle.java index 3bb7910d8ec..8a1fdd030e9 100644 --- a/JCL/converterJclMin15/src/java/lang/invoke/MethodHandle.java +++ b/JCL/converterJclMin15/src/java/lang/invoke/MethodHandle.java @@ -1,38 +1,38 @@ -package java.lang.invoke; -/******************************************************************************* - * Copyright (c) 2011 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - - -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -public abstract class MethodHandle { - @Target(METHOD) - @Retention(RUNTIME) - @interface PolymorphicSignature { - } - - @PolymorphicSignature - public final native Object invoke(Object... args) throws Throwable; - - @PolymorphicSignature - public final native Object invokeExact(Object... args) throws Throwable; - - public native Object invokeWithArguments(Object... arguments) - throws Throwable; - - public native boolean isVarargsCollector(); - - public native MethodHandle asType(MethodType newType); +package java.lang.invoke; +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +public abstract class MethodHandle { + @Target(METHOD) + @Retention(RUNTIME) + @interface PolymorphicSignature { + } + + @PolymorphicSignature + public final native Object invoke(Object... args) throws Throwable; + + @PolymorphicSignature + public final native Object invokeExact(Object... args) throws Throwable; + + public native Object invokeWithArguments(Object... arguments) + throws Throwable; + + public native boolean isVarargsCollector(); + + public native MethodHandle asType(MethodType newType); } \ No newline at end of file diff --git a/JCL/converterJclMin15/src/java/lang/invoke/MethodHandles.java b/JCL/converterJclMin15/src/java/lang/invoke/MethodHandles.java index 33622371faf..f40dc8200bc 100644 --- a/JCL/converterJclMin15/src/java/lang/invoke/MethodHandles.java +++ b/JCL/converterJclMin15/src/java/lang/invoke/MethodHandles.java @@ -1,21 +1,21 @@ -package java.lang.invoke; - -public class MethodHandles { - public static final class Lookup { - public MethodHandle findVirtual(Class refc, String name, - MethodType type) throws NoSuchMethodException, - IllegalAccessException { - return null; - } - - public MethodHandle findStatic(Class refc, String name, - MethodType type) throws NoSuchMethodException, - IllegalAccessException { - return null; - } - } - - public static Lookup lookup() { - return null; - } -} +package java.lang.invoke; + +public class MethodHandles { + public static final class Lookup { + public MethodHandle findVirtual(Class refc, String name, + MethodType type) throws NoSuchMethodException, + IllegalAccessException { + return null; + } + + public MethodHandle findStatic(Class refc, String name, + MethodType type) throws NoSuchMethodException, + IllegalAccessException { + return null; + } + } + + public static Lookup lookup() { + return null; + } +} diff --git a/JCL/converterJclMin15/src/java/lang/invoke/MethodType.java b/JCL/converterJclMin15/src/java/lang/invoke/MethodType.java index 802a3f2c806..90a46dc8fea 100644 --- a/JCL/converterJclMin15/src/java/lang/invoke/MethodType.java +++ b/JCL/converterJclMin15/src/java/lang/invoke/MethodType.java @@ -1,17 +1,17 @@ -package java.lang.invoke; - - -public final class MethodType { - public static MethodType methodType(Class rtype, Class ptype0, - Class... ptypes) { - return null; - } - - public static MethodType methodType(Class rtype) { - return null; - } - - public static MethodType genericMethodType(int objectArgCount) { - return null; - } -} +package java.lang.invoke; + + +public final class MethodType { + public static MethodType methodType(Class rtype, Class ptype0, + Class... ptypes) { + return null; + } + + public static MethodType methodType(Class rtype) { + return null; + } + + public static MethodType genericMethodType(int objectArgCount) { + return null; + } +} diff --git a/JCL/converterJclMin15/src/java/util/Collection.java b/JCL/converterJclMin15/src/java/util/Collection.java index a40b2d29a3f..c6fb16779ce 100644 --- a/JCL/converterJclMin15/src/java/util/Collection.java +++ b/JCL/converterJclMin15/src/java/util/Collection.java @@ -1,9 +1,9 @@ -package java.util; - -public interface Collection extends Iterable { - public Iterator iterator(); - public int size(); - public T get(int index); - public boolean addAll(Collection c); - public T[] toArray(T[] o); -} +package java.util; + +public interface Collection extends Iterable { + public Iterator iterator(); + public int size(); + public T get(int index); + public boolean addAll(Collection c); + public T[] toArray(T[] o); +} diff --git a/JCL/converterJclMin15/src/java/util/Iterator.java b/JCL/converterJclMin15/src/java/util/Iterator.java index f90ee762c2f..ae53f8408e0 100644 --- a/JCL/converterJclMin15/src/java/util/Iterator.java +++ b/JCL/converterJclMin15/src/java/util/Iterator.java @@ -1,7 +1,7 @@ -package java.util; - -public interface Iterator { - boolean hasNext(); - E next(); - void remove(); -} +package java.util; + +public interface Iterator { + boolean hasNext(); + E next(); + void remove(); +} diff --git a/JCL/converterJclMin15/src/java/util/List.java b/JCL/converterJclMin15/src/java/util/List.java index 7d19bdfb1b8..4565ccb902f 100644 --- a/JCL/converterJclMin15/src/java/util/List.java +++ b/JCL/converterJclMin15/src/java/util/List.java @@ -1,4 +1,4 @@ -package java.util; - -public interface List extends Collection { -} +package java.util; + +public interface List extends Collection { +} diff --git a/JCL/converterJclMin15/src/java/util/Map.java b/JCL/converterJclMin15/src/java/util/Map.java index 574a7f816a5..f47752cfdba 100644 --- a/JCL/converterJclMin15/src/java/util/Map.java +++ b/JCL/converterJclMin15/src/java/util/Map.java @@ -1,5 +1,5 @@ -package java.util; - -public interface Map { - +package java.util; + +public interface Map { + } \ No newline at end of file diff --git a/JCL/converterJclMin17/src/java/io/Serializable.java b/JCL/converterJclMin17/src/java/io/Serializable.java index edd882d7d58..3629567396a 100644 --- a/JCL/converterJclMin17/src/java/io/Serializable.java +++ b/JCL/converterJclMin17/src/java/io/Serializable.java @@ -1,4 +1,4 @@ -package java.io; - -public interface Serializable { -} +package java.io; + +public interface Serializable { +} diff --git a/JCL/converterJclMin17/src/java/lang/CharSequence.java b/JCL/converterJclMin17/src/java/lang/CharSequence.java index b9a0d9e4176..b03fc9e823b 100644 --- a/JCL/converterJclMin17/src/java/lang/CharSequence.java +++ b/JCL/converterJclMin17/src/java/lang/CharSequence.java @@ -1,5 +1,5 @@ -package java.lang; - -public interface CharSequence { - int length(); -} +package java.lang; + +public interface CharSequence { + int length(); +} diff --git a/JCL/converterJclMin17/src/java/lang/Class.java b/JCL/converterJclMin17/src/java/lang/Class.java index a7667b98347..7d08bf1f389 100644 --- a/JCL/converterJclMin17/src/java/lang/Class.java +++ b/JCL/converterJclMin17/src/java/lang/Class.java @@ -1,4 +1,4 @@ -package java.lang; - -public class Class { -} +package java.lang; + +public class Class { +} diff --git a/JCL/converterJclMin17/src/java/lang/CloneNotSupportedException.java b/JCL/converterJclMin17/src/java/lang/CloneNotSupportedException.java index cb777dc7bac..6f05a932fab 100644 --- a/JCL/converterJclMin17/src/java/lang/CloneNotSupportedException.java +++ b/JCL/converterJclMin17/src/java/lang/CloneNotSupportedException.java @@ -1,4 +1,4 @@ -package java.lang; - -public class CloneNotSupportedException extends Exception { -} +package java.lang; + +public class CloneNotSupportedException extends Exception { +} diff --git a/JCL/converterJclMin17/src/java/lang/Comparable.java b/JCL/converterJclMin17/src/java/lang/Comparable.java index fbc6c8bac34..59fb9eddd47 100644 --- a/JCL/converterJclMin17/src/java/lang/Comparable.java +++ b/JCL/converterJclMin17/src/java/lang/Comparable.java @@ -1,4 +1,4 @@ -package java.lang; - -public interface Comparable { -} +package java.lang; + +public interface Comparable { +} diff --git a/JCL/converterJclMin17/src/java/lang/Deprecated.java b/JCL/converterJclMin17/src/java/lang/Deprecated.java index 6c73dedd0d1..5226e586c7e 100644 --- a/JCL/converterJclMin17/src/java/lang/Deprecated.java +++ b/JCL/converterJclMin17/src/java/lang/Deprecated.java @@ -1,6 +1,6 @@ -package java.lang; -import java.lang.annotation.*; -@Documented -@Retention(RetentionPolicy.RUNTIME) -public @interface Deprecated { +package java.lang; +import java.lang.annotation.*; +@Documented +@Retention(RetentionPolicy.RUNTIME) +public @interface Deprecated { } \ No newline at end of file diff --git a/JCL/converterJclMin17/src/java/lang/Enum.java b/JCL/converterJclMin17/src/java/lang/Enum.java index a510103e609..f68f11eacec 100644 --- a/JCL/converterJclMin17/src/java/lang/Enum.java +++ b/JCL/converterJclMin17/src/java/lang/Enum.java @@ -1,18 +1,18 @@ -package java.lang; - -public abstract class Enum> implements Comparable, java.io.Serializable { - private static final long serialVersionUID = 2L; - - protected Enum(String name, int ordinal) { - } - public final String name() { - return null; - } - public final int ordinal() { - return 0; - } - public static > T valueOf(Class enumClass, - String name) { - return null; - } -} +package java.lang; + +public abstract class Enum> implements Comparable, java.io.Serializable { + private static final long serialVersionUID = 2L; + + protected Enum(String name, int ordinal) { + } + public final String name() { + return null; + } + public final int ordinal() { + return 0; + } + public static > T valueOf(Class enumClass, + String name) { + return null; + } +} diff --git a/JCL/converterJclMin17/src/java/lang/Error.java b/JCL/converterJclMin17/src/java/lang/Error.java index 9a446d53249..820d8c62226 100644 --- a/JCL/converterJclMin17/src/java/lang/Error.java +++ b/JCL/converterJclMin17/src/java/lang/Error.java @@ -1,16 +1,16 @@ -package java.lang; - -public class Error extends Throwable { - - public Error(java.lang.String s) { - // TODO Auto-generated constructor stub - } - - public Error(java.lang.String s, java.lang.Throwable cause) { - // TODO Auto-generated constructor stub - } - - public Error() { - // TODO Auto-generated constructor stub - } -} +package java.lang; + +public class Error extends Throwable { + + public Error(java.lang.String s) { + // TODO Auto-generated constructor stub + } + + public Error(java.lang.String s, java.lang.Throwable cause) { + // TODO Auto-generated constructor stub + } + + public Error() { + // TODO Auto-generated constructor stub + } +} diff --git a/JCL/converterJclMin17/src/java/lang/Exception.java b/JCL/converterJclMin17/src/java/lang/Exception.java index 0adef36baff..88b222a9c06 100644 --- a/JCL/converterJclMin17/src/java/lang/Exception.java +++ b/JCL/converterJclMin17/src/java/lang/Exception.java @@ -1,19 +1,19 @@ -package java.lang; - -public class Exception extends Throwable { - public Exception() { - super(); - } - - public Exception(String message) { - super(message); - } - - public Exception(String message, Throwable cause) { - super(message, cause); - } - - public Exception(Throwable cause) { - super(cause); - } -} +package java.lang; + +public class Exception extends Throwable { + public Exception() { + super(); + } + + public Exception(String message) { + super(message); + } + + public Exception(String message, Throwable cause) { + super(message, cause); + } + + public Exception(Throwable cause) { + super(cause); + } +} diff --git a/JCL/converterJclMin17/src/java/lang/IllegalAccessException.java b/JCL/converterJclMin17/src/java/lang/IllegalAccessException.java index 814649067f6..0d13e1e0571 100644 --- a/JCL/converterJclMin17/src/java/lang/IllegalAccessException.java +++ b/JCL/converterJclMin17/src/java/lang/IllegalAccessException.java @@ -1,5 +1,5 @@ -package java.lang; - -public class IllegalAccessException extends RuntimeException { - -} +package java.lang; + +public class IllegalAccessException extends RuntimeException { + +} diff --git a/JCL/converterJclMin17/src/java/lang/IllegalMonitorStateException.java b/JCL/converterJclMin17/src/java/lang/IllegalMonitorStateException.java index e173f133abe..1f67418128c 100644 --- a/JCL/converterJclMin17/src/java/lang/IllegalMonitorStateException.java +++ b/JCL/converterJclMin17/src/java/lang/IllegalMonitorStateException.java @@ -1,4 +1,4 @@ -package java.lang; - -public class IllegalMonitorStateException extends RuntimeException { -} +package java.lang; + +public class IllegalMonitorStateException extends RuntimeException { +} diff --git a/JCL/converterJclMin17/src/java/lang/InterruptedException.java b/JCL/converterJclMin17/src/java/lang/InterruptedException.java index e2e84ba0bc2..93b236c4210 100644 --- a/JCL/converterJclMin17/src/java/lang/InterruptedException.java +++ b/JCL/converterJclMin17/src/java/lang/InterruptedException.java @@ -1,4 +1,4 @@ -package java.lang; - -public class InterruptedException extends Exception { -} +package java.lang; + +public class InterruptedException extends Exception { +} diff --git a/JCL/converterJclMin17/src/java/lang/NoSuchMethodException.java b/JCL/converterJclMin17/src/java/lang/NoSuchMethodException.java index b8c5bce7a5b..3dd142bdd33 100644 --- a/JCL/converterJclMin17/src/java/lang/NoSuchMethodException.java +++ b/JCL/converterJclMin17/src/java/lang/NoSuchMethodException.java @@ -1,5 +1,5 @@ -package java.lang; - -public class NoSuchMethodException extends RuntimeException { - -} +package java.lang; + +public class NoSuchMethodException extends RuntimeException { + +} diff --git a/JCL/converterJclMin17/src/java/lang/Object.java b/JCL/converterJclMin17/src/java/lang/Object.java index eb50899e5ba..71ddb4ff834 100644 --- a/JCL/converterJclMin17/src/java/lang/Object.java +++ b/JCL/converterJclMin17/src/java/lang/Object.java @@ -1,34 +1,34 @@ -package java.lang; - -public class Object { - -public Object() { -} -protected Object clone() throws CloneNotSupportedException { - return null; -} -public boolean equals (Object obj) { - return false; -} -protected void finalize () throws Throwable { -} -public final Class getClass() { - return null; -} -public int hashCode() { - return -1; -} -public final void notify() throws IllegalMonitorStateException { -} -public final void notifyAll() throws IllegalMonitorStateException { -} -public String toString () { - return null; -} -public final void wait () throws IllegalMonitorStateException, InterruptedException { -} -public final void wait (long millis) throws IllegalMonitorStateException, InterruptedException { -} -public final void wait (long millis, int nanos) throws IllegalMonitorStateException, InterruptedException { -} -} +package java.lang; + +public class Object { + +public Object() { +} +protected Object clone() throws CloneNotSupportedException { + return null; +} +public boolean equals (Object obj) { + return false; +} +protected void finalize () throws Throwable { +} +public final Class getClass() { + return null; +} +public int hashCode() { + return -1; +} +public final void notify() throws IllegalMonitorStateException { +} +public final void notifyAll() throws IllegalMonitorStateException { +} +public String toString () { + return null; +} +public final void wait () throws IllegalMonitorStateException, InterruptedException { +} +public final void wait (long millis) throws IllegalMonitorStateException, InterruptedException { +} +public final void wait (long millis, int nanos) throws IllegalMonitorStateException, InterruptedException { +} +} diff --git a/JCL/converterJclMin17/src/java/lang/RuntimeException.java b/JCL/converterJclMin17/src/java/lang/RuntimeException.java index 80dc1dbd34e..3d94712d7f8 100644 --- a/JCL/converterJclMin17/src/java/lang/RuntimeException.java +++ b/JCL/converterJclMin17/src/java/lang/RuntimeException.java @@ -1,12 +1,12 @@ -package java.lang; - -public class RuntimeException extends Exception { - - public RuntimeException(java.lang.String s) { - // TODO Auto-generated constructor stub - } - - public RuntimeException() { - // TODO Auto-generated constructor stub - } -} +package java.lang; + +public class RuntimeException extends Exception { + + public RuntimeException(java.lang.String s) { + // TODO Auto-generated constructor stub + } + + public RuntimeException() { + // TODO Auto-generated constructor stub + } +} diff --git a/JCL/converterJclMin17/src/java/lang/String.java b/JCL/converterJclMin17/src/java/lang/String.java index ba6bf08bf4f..64f759b78be 100644 --- a/JCL/converterJclMin17/src/java/lang/String.java +++ b/JCL/converterJclMin17/src/java/lang/String.java @@ -1,8 +1,8 @@ -package java.lang; - -public class String implements CharSequence { - public int length() { return 0; } - public int codePointAt(int index) { - return 0; - } -} +package java.lang; + +public class String implements CharSequence { + public int length() { return 0; } + public int codePointAt(int index) { + return 0; + } +} diff --git a/JCL/converterJclMin17/src/java/lang/Throwable.java b/JCL/converterJclMin17/src/java/lang/Throwable.java index 2488269bebc..73ab84b6950 100644 --- a/JCL/converterJclMin17/src/java/lang/Throwable.java +++ b/JCL/converterJclMin17/src/java/lang/Throwable.java @@ -1,20 +1,20 @@ -package java.lang; - -public class Throwable { - - public Throwable(java.lang.String message) { - // TODO Auto-generated constructor stub - } - - public Throwable() { - // TODO Auto-generated constructor stub - } - - public Throwable(java.lang.String message, Throwable cause) { - // TODO Auto-generated constructor stub - } - - public Throwable(Throwable cause) { - // TODO Auto-generated constructor stub - } -} +package java.lang; + +public class Throwable { + + public Throwable(java.lang.String message) { + // TODO Auto-generated constructor stub + } + + public Throwable() { + // TODO Auto-generated constructor stub + } + + public Throwable(java.lang.String message, Throwable cause) { + // TODO Auto-generated constructor stub + } + + public Throwable(Throwable cause) { + // TODO Auto-generated constructor stub + } +} diff --git a/JCL/converterJclMin17/src/java/lang/annotation/Annotation.java b/JCL/converterJclMin17/src/java/lang/annotation/Annotation.java index ba72aad15ec..530c272ea43 100644 --- a/JCL/converterJclMin17/src/java/lang/annotation/Annotation.java +++ b/JCL/converterJclMin17/src/java/lang/annotation/Annotation.java @@ -1,4 +1,4 @@ -package java.lang.annotation; -public interface Annotation { - -} +package java.lang.annotation; +public interface Annotation { + +} diff --git a/JCL/converterJclMin17/src/java/lang/annotation/Documented.java b/JCL/converterJclMin17/src/java/lang/annotation/Documented.java index 34494fb5f33..b70fc969617 100644 --- a/JCL/converterJclMin17/src/java/lang/annotation/Documented.java +++ b/JCL/converterJclMin17/src/java/lang/annotation/Documented.java @@ -1,12 +1,12 @@ -package java.lang.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface Documented { -} +package java.lang.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.ANNOTATION_TYPE) +public @interface Documented { +} diff --git a/JCL/converterJclMin17/src/java/lang/annotation/Inherited.java b/JCL/converterJclMin17/src/java/lang/annotation/Inherited.java index 9753e0c4127..e51219ed399 100644 --- a/JCL/converterJclMin17/src/java/lang/annotation/Inherited.java +++ b/JCL/converterJclMin17/src/java/lang/annotation/Inherited.java @@ -1,13 +1,13 @@ -package java.lang.annotation; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface Inherited { +package java.lang.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.ANNOTATION_TYPE) +public @interface Inherited { } \ No newline at end of file diff --git a/JCL/converterJclMin17/src/java/lang/annotation/Retention.java b/JCL/converterJclMin17/src/java/lang/annotation/Retention.java index 72f141758b4..9a23c8186db 100644 --- a/JCL/converterJclMin17/src/java/lang/annotation/Retention.java +++ b/JCL/converterJclMin17/src/java/lang/annotation/Retention.java @@ -1,14 +1,14 @@ -package java.lang.annotation; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface Retention { - RetentionPolicy value(); +package java.lang.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.ANNOTATION_TYPE) +public @interface Retention { + RetentionPolicy value(); } \ No newline at end of file diff --git a/JCL/converterJclMin17/src/java/lang/annotation/RetentionPolicy.java b/JCL/converterJclMin17/src/java/lang/annotation/RetentionPolicy.java index b69fa7d6544..26349b19198 100644 --- a/JCL/converterJclMin17/src/java/lang/annotation/RetentionPolicy.java +++ b/JCL/converterJclMin17/src/java/lang/annotation/RetentionPolicy.java @@ -1,6 +1,6 @@ -package java.lang.annotation; -public enum RetentionPolicy { - CLASS, - SOURCE, - RUNTIME +package java.lang.annotation; +public enum RetentionPolicy { + CLASS, + SOURCE, + RUNTIME } \ No newline at end of file diff --git a/JCL/converterJclMin17/src/java/lang/annotation/Target.java b/JCL/converterJclMin17/src/java/lang/annotation/Target.java index 239f6b1ee6a..8cd620502ac 100644 --- a/JCL/converterJclMin17/src/java/lang/annotation/Target.java +++ b/JCL/converterJclMin17/src/java/lang/annotation/Target.java @@ -1,14 +1,14 @@ -package java.lang.annotation; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface Target { - ElementType[] value(); +package java.lang.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.ANNOTATION_TYPE) +public @interface Target { + ElementType[] value(); } \ No newline at end of file diff --git a/JCL/converterJclMin17/src/java/lang/invoke/MethodHandle.java b/JCL/converterJclMin17/src/java/lang/invoke/MethodHandle.java index 789476586da..69736475bd0 100644 --- a/JCL/converterJclMin17/src/java/lang/invoke/MethodHandle.java +++ b/JCL/converterJclMin17/src/java/lang/invoke/MethodHandle.java @@ -1,39 +1,39 @@ -package java.lang.invoke; -/******************************************************************************* - * Copyright (c) 2011 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - - -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; -import java.lang.invoke.MethodType; - -public abstract class MethodHandle { - @Target(METHOD) - @Retention(RUNTIME) - @interface PolymorphicSignature { - } - - @PolymorphicSignature - public final native Object invoke(Object... args) throws Throwable; - - @PolymorphicSignature - public final native Object invokeExact(Object... args) throws Throwable; - - public native Object invokeWithArguments(Object... arguments) - throws Throwable; - - public native boolean isVarargsCollector(); - - public native MethodHandle asType(MethodType newType); +package java.lang.invoke; +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; +import java.lang.invoke.MethodType; + +public abstract class MethodHandle { + @Target(METHOD) + @Retention(RUNTIME) + @interface PolymorphicSignature { + } + + @PolymorphicSignature + public final native Object invoke(Object... args) throws Throwable; + + @PolymorphicSignature + public final native Object invokeExact(Object... args) throws Throwable; + + public native Object invokeWithArguments(Object... arguments) + throws Throwable; + + public native boolean isVarargsCollector(); + + public native MethodHandle asType(MethodType newType); } \ No newline at end of file diff --git a/JCL/converterJclMin17/src/java/lang/invoke/MethodHandles.java b/JCL/converterJclMin17/src/java/lang/invoke/MethodHandles.java index 49d9f1f87ab..582995d9d86 100644 --- a/JCL/converterJclMin17/src/java/lang/invoke/MethodHandles.java +++ b/JCL/converterJclMin17/src/java/lang/invoke/MethodHandles.java @@ -1,22 +1,22 @@ -package java.lang.invoke; -import java.lang.invoke.MethodType; - -public class MethodHandles { - public static final class Lookup { - public MethodHandle findVirtual(Class refc, String name, - MethodType type) throws NoSuchMethodException, - IllegalAccessException { - return null; - } - - public MethodHandle findStatic(Class refc, String name, - MethodType type) throws NoSuchMethodException, - IllegalAccessException { - return null; - } - } - - public static Lookup lookup() { - return null; - } -} +package java.lang.invoke; +import java.lang.invoke.MethodType; + +public class MethodHandles { + public static final class Lookup { + public MethodHandle findVirtual(Class refc, String name, + MethodType type) throws NoSuchMethodException, + IllegalAccessException { + return null; + } + + public MethodHandle findStatic(Class refc, String name, + MethodType type) throws NoSuchMethodException, + IllegalAccessException { + return null; + } + } + + public static Lookup lookup() { + return null; + } +} diff --git a/JCL/converterJclMin17/src/java/lang/invoke/MethodType.java b/JCL/converterJclMin17/src/java/lang/invoke/MethodType.java index 802a3f2c806..90a46dc8fea 100644 --- a/JCL/converterJclMin17/src/java/lang/invoke/MethodType.java +++ b/JCL/converterJclMin17/src/java/lang/invoke/MethodType.java @@ -1,17 +1,17 @@ -package java.lang.invoke; - - -public final class MethodType { - public static MethodType methodType(Class rtype, Class ptype0, - Class... ptypes) { - return null; - } - - public static MethodType methodType(Class rtype) { - return null; - } - - public static MethodType genericMethodType(int objectArgCount) { - return null; - } -} +package java.lang.invoke; + + +public final class MethodType { + public static MethodType methodType(Class rtype, Class ptype0, + Class... ptypes) { + return null; + } + + public static MethodType methodType(Class rtype) { + return null; + } + + public static MethodType genericMethodType(int objectArgCount) { + return null; + } +} diff --git a/JCL/converterJclMin17/src/java/util/Collection.java b/JCL/converterJclMin17/src/java/util/Collection.java index a40b2d29a3f..c6fb16779ce 100644 --- a/JCL/converterJclMin17/src/java/util/Collection.java +++ b/JCL/converterJclMin17/src/java/util/Collection.java @@ -1,9 +1,9 @@ -package java.util; - -public interface Collection extends Iterable { - public Iterator iterator(); - public int size(); - public T get(int index); - public boolean addAll(Collection c); - public T[] toArray(T[] o); -} +package java.util; + +public interface Collection extends Iterable { + public Iterator iterator(); + public int size(); + public T get(int index); + public boolean addAll(Collection c); + public T[] toArray(T[] o); +} diff --git a/JCL/converterJclMin17/src/java/util/Iterator.java b/JCL/converterJclMin17/src/java/util/Iterator.java index f90ee762c2f..ae53f8408e0 100644 --- a/JCL/converterJclMin17/src/java/util/Iterator.java +++ b/JCL/converterJclMin17/src/java/util/Iterator.java @@ -1,7 +1,7 @@ -package java.util; - -public interface Iterator { - boolean hasNext(); - E next(); - void remove(); -} +package java.util; + +public interface Iterator { + boolean hasNext(); + E next(); + void remove(); +} diff --git a/JCL/converterJclMin17/src/java/util/List.java b/JCL/converterJclMin17/src/java/util/List.java index 7d19bdfb1b8..4565ccb902f 100644 --- a/JCL/converterJclMin17/src/java/util/List.java +++ b/JCL/converterJclMin17/src/java/util/List.java @@ -1,4 +1,4 @@ -package java.util; - -public interface List extends Collection { -} +package java.util; + +public interface List extends Collection { +} diff --git a/JCL/converterJclMin17/src/java/util/Map.java b/JCL/converterJclMin17/src/java/util/Map.java index 574a7f816a5..f47752cfdba 100644 --- a/JCL/converterJclMin17/src/java/util/Map.java +++ b/JCL/converterJclMin17/src/java/util/Map.java @@ -1,5 +1,5 @@ -package java.util; - -public interface Map { - +package java.util; + +public interface Map { + } \ No newline at end of file diff --git a/JCL/converterJclMin18/src/java/io/Serializable.java b/JCL/converterJclMin18/src/java/io/Serializable.java index edd882d7d58..3629567396a 100644 --- a/JCL/converterJclMin18/src/java/io/Serializable.java +++ b/JCL/converterJclMin18/src/java/io/Serializable.java @@ -1,4 +1,4 @@ -package java.io; - -public interface Serializable { -} +package java.io; + +public interface Serializable { +} diff --git a/JCL/converterJclMin18/src/java/lang/CharSequence.java b/JCL/converterJclMin18/src/java/lang/CharSequence.java index b9a0d9e4176..b03fc9e823b 100644 --- a/JCL/converterJclMin18/src/java/lang/CharSequence.java +++ b/JCL/converterJclMin18/src/java/lang/CharSequence.java @@ -1,5 +1,5 @@ -package java.lang; - -public interface CharSequence { - int length(); -} +package java.lang; + +public interface CharSequence { + int length(); +} diff --git a/JCL/converterJclMin18/src/java/lang/Class.java b/JCL/converterJclMin18/src/java/lang/Class.java index a7667b98347..7d08bf1f389 100644 --- a/JCL/converterJclMin18/src/java/lang/Class.java +++ b/JCL/converterJclMin18/src/java/lang/Class.java @@ -1,4 +1,4 @@ -package java.lang; - -public class Class { -} +package java.lang; + +public class Class { +} diff --git a/JCL/converterJclMin18/src/java/lang/CloneNotSupportedException.java b/JCL/converterJclMin18/src/java/lang/CloneNotSupportedException.java index cb777dc7bac..6f05a932fab 100644 --- a/JCL/converterJclMin18/src/java/lang/CloneNotSupportedException.java +++ b/JCL/converterJclMin18/src/java/lang/CloneNotSupportedException.java @@ -1,4 +1,4 @@ -package java.lang; - -public class CloneNotSupportedException extends Exception { -} +package java.lang; + +public class CloneNotSupportedException extends Exception { +} diff --git a/JCL/converterJclMin18/src/java/lang/Comparable.java b/JCL/converterJclMin18/src/java/lang/Comparable.java index fbc6c8bac34..59fb9eddd47 100644 --- a/JCL/converterJclMin18/src/java/lang/Comparable.java +++ b/JCL/converterJclMin18/src/java/lang/Comparable.java @@ -1,4 +1,4 @@ -package java.lang; - -public interface Comparable { -} +package java.lang; + +public interface Comparable { +} diff --git a/JCL/converterJclMin18/src/java/lang/Deprecated.java b/JCL/converterJclMin18/src/java/lang/Deprecated.java index 6c73dedd0d1..5226e586c7e 100644 --- a/JCL/converterJclMin18/src/java/lang/Deprecated.java +++ b/JCL/converterJclMin18/src/java/lang/Deprecated.java @@ -1,6 +1,6 @@ -package java.lang; -import java.lang.annotation.*; -@Documented -@Retention(RetentionPolicy.RUNTIME) -public @interface Deprecated { +package java.lang; +import java.lang.annotation.*; +@Documented +@Retention(RetentionPolicy.RUNTIME) +public @interface Deprecated { } \ No newline at end of file diff --git a/JCL/converterJclMin18/src/java/lang/Enum.java b/JCL/converterJclMin18/src/java/lang/Enum.java index a510103e609..f68f11eacec 100644 --- a/JCL/converterJclMin18/src/java/lang/Enum.java +++ b/JCL/converterJclMin18/src/java/lang/Enum.java @@ -1,18 +1,18 @@ -package java.lang; - -public abstract class Enum> implements Comparable, java.io.Serializable { - private static final long serialVersionUID = 2L; - - protected Enum(String name, int ordinal) { - } - public final String name() { - return null; - } - public final int ordinal() { - return 0; - } - public static > T valueOf(Class enumClass, - String name) { - return null; - } -} +package java.lang; + +public abstract class Enum> implements Comparable, java.io.Serializable { + private static final long serialVersionUID = 2L; + + protected Enum(String name, int ordinal) { + } + public final String name() { + return null; + } + public final int ordinal() { + return 0; + } + public static > T valueOf(Class enumClass, + String name) { + return null; + } +} diff --git a/JCL/converterJclMin18/src/java/lang/Error.java b/JCL/converterJclMin18/src/java/lang/Error.java index 9a446d53249..820d8c62226 100644 --- a/JCL/converterJclMin18/src/java/lang/Error.java +++ b/JCL/converterJclMin18/src/java/lang/Error.java @@ -1,16 +1,16 @@ -package java.lang; - -public class Error extends Throwable { - - public Error(java.lang.String s) { - // TODO Auto-generated constructor stub - } - - public Error(java.lang.String s, java.lang.Throwable cause) { - // TODO Auto-generated constructor stub - } - - public Error() { - // TODO Auto-generated constructor stub - } -} +package java.lang; + +public class Error extends Throwable { + + public Error(java.lang.String s) { + // TODO Auto-generated constructor stub + } + + public Error(java.lang.String s, java.lang.Throwable cause) { + // TODO Auto-generated constructor stub + } + + public Error() { + // TODO Auto-generated constructor stub + } +} diff --git a/JCL/converterJclMin18/src/java/lang/Exception.java b/JCL/converterJclMin18/src/java/lang/Exception.java index 0adef36baff..88b222a9c06 100644 --- a/JCL/converterJclMin18/src/java/lang/Exception.java +++ b/JCL/converterJclMin18/src/java/lang/Exception.java @@ -1,19 +1,19 @@ -package java.lang; - -public class Exception extends Throwable { - public Exception() { - super(); - } - - public Exception(String message) { - super(message); - } - - public Exception(String message, Throwable cause) { - super(message, cause); - } - - public Exception(Throwable cause) { - super(cause); - } -} +package java.lang; + +public class Exception extends Throwable { + public Exception() { + super(); + } + + public Exception(String message) { + super(message); + } + + public Exception(String message, Throwable cause) { + super(message, cause); + } + + public Exception(Throwable cause) { + super(cause); + } +} diff --git a/JCL/converterJclMin18/src/java/lang/IllegalAccessException.java b/JCL/converterJclMin18/src/java/lang/IllegalAccessException.java index 814649067f6..0d13e1e0571 100644 --- a/JCL/converterJclMin18/src/java/lang/IllegalAccessException.java +++ b/JCL/converterJclMin18/src/java/lang/IllegalAccessException.java @@ -1,5 +1,5 @@ -package java.lang; - -public class IllegalAccessException extends RuntimeException { - -} +package java.lang; + +public class IllegalAccessException extends RuntimeException { + +} diff --git a/JCL/converterJclMin18/src/java/lang/IllegalMonitorStateException.java b/JCL/converterJclMin18/src/java/lang/IllegalMonitorStateException.java index e173f133abe..1f67418128c 100644 --- a/JCL/converterJclMin18/src/java/lang/IllegalMonitorStateException.java +++ b/JCL/converterJclMin18/src/java/lang/IllegalMonitorStateException.java @@ -1,4 +1,4 @@ -package java.lang; - -public class IllegalMonitorStateException extends RuntimeException { -} +package java.lang; + +public class IllegalMonitorStateException extends RuntimeException { +} diff --git a/JCL/converterJclMin18/src/java/lang/InterruptedException.java b/JCL/converterJclMin18/src/java/lang/InterruptedException.java index e2e84ba0bc2..93b236c4210 100644 --- a/JCL/converterJclMin18/src/java/lang/InterruptedException.java +++ b/JCL/converterJclMin18/src/java/lang/InterruptedException.java @@ -1,4 +1,4 @@ -package java.lang; - -public class InterruptedException extends Exception { -} +package java.lang; + +public class InterruptedException extends Exception { +} diff --git a/JCL/converterJclMin18/src/java/lang/NoSuchMethodException.java b/JCL/converterJclMin18/src/java/lang/NoSuchMethodException.java index b8c5bce7a5b..3dd142bdd33 100644 --- a/JCL/converterJclMin18/src/java/lang/NoSuchMethodException.java +++ b/JCL/converterJclMin18/src/java/lang/NoSuchMethodException.java @@ -1,5 +1,5 @@ -package java.lang; - -public class NoSuchMethodException extends RuntimeException { - -} +package java.lang; + +public class NoSuchMethodException extends RuntimeException { + +} diff --git a/JCL/converterJclMin18/src/java/lang/Object.java b/JCL/converterJclMin18/src/java/lang/Object.java index eb50899e5ba..71ddb4ff834 100644 --- a/JCL/converterJclMin18/src/java/lang/Object.java +++ b/JCL/converterJclMin18/src/java/lang/Object.java @@ -1,34 +1,34 @@ -package java.lang; - -public class Object { - -public Object() { -} -protected Object clone() throws CloneNotSupportedException { - return null; -} -public boolean equals (Object obj) { - return false; -} -protected void finalize () throws Throwable { -} -public final Class getClass() { - return null; -} -public int hashCode() { - return -1; -} -public final void notify() throws IllegalMonitorStateException { -} -public final void notifyAll() throws IllegalMonitorStateException { -} -public String toString () { - return null; -} -public final void wait () throws IllegalMonitorStateException, InterruptedException { -} -public final void wait (long millis) throws IllegalMonitorStateException, InterruptedException { -} -public final void wait (long millis, int nanos) throws IllegalMonitorStateException, InterruptedException { -} -} +package java.lang; + +public class Object { + +public Object() { +} +protected Object clone() throws CloneNotSupportedException { + return null; +} +public boolean equals (Object obj) { + return false; +} +protected void finalize () throws Throwable { +} +public final Class getClass() { + return null; +} +public int hashCode() { + return -1; +} +public final void notify() throws IllegalMonitorStateException { +} +public final void notifyAll() throws IllegalMonitorStateException { +} +public String toString () { + return null; +} +public final void wait () throws IllegalMonitorStateException, InterruptedException { +} +public final void wait (long millis) throws IllegalMonitorStateException, InterruptedException { +} +public final void wait (long millis, int nanos) throws IllegalMonitorStateException, InterruptedException { +} +} diff --git a/JCL/converterJclMin18/src/java/lang/RuntimeException.java b/JCL/converterJclMin18/src/java/lang/RuntimeException.java index 80dc1dbd34e..3d94712d7f8 100644 --- a/JCL/converterJclMin18/src/java/lang/RuntimeException.java +++ b/JCL/converterJclMin18/src/java/lang/RuntimeException.java @@ -1,12 +1,12 @@ -package java.lang; - -public class RuntimeException extends Exception { - - public RuntimeException(java.lang.String s) { - // TODO Auto-generated constructor stub - } - - public RuntimeException() { - // TODO Auto-generated constructor stub - } -} +package java.lang; + +public class RuntimeException extends Exception { + + public RuntimeException(java.lang.String s) { + // TODO Auto-generated constructor stub + } + + public RuntimeException() { + // TODO Auto-generated constructor stub + } +} diff --git a/JCL/converterJclMin18/src/java/lang/String.java b/JCL/converterJclMin18/src/java/lang/String.java index ba6bf08bf4f..64f759b78be 100644 --- a/JCL/converterJclMin18/src/java/lang/String.java +++ b/JCL/converterJclMin18/src/java/lang/String.java @@ -1,8 +1,8 @@ -package java.lang; - -public class String implements CharSequence { - public int length() { return 0; } - public int codePointAt(int index) { - return 0; - } -} +package java.lang; + +public class String implements CharSequence { + public int length() { return 0; } + public int codePointAt(int index) { + return 0; + } +} diff --git a/JCL/converterJclMin18/src/java/lang/Throwable.java b/JCL/converterJclMin18/src/java/lang/Throwable.java index 2488269bebc..73ab84b6950 100644 --- a/JCL/converterJclMin18/src/java/lang/Throwable.java +++ b/JCL/converterJclMin18/src/java/lang/Throwable.java @@ -1,20 +1,20 @@ -package java.lang; - -public class Throwable { - - public Throwable(java.lang.String message) { - // TODO Auto-generated constructor stub - } - - public Throwable() { - // TODO Auto-generated constructor stub - } - - public Throwable(java.lang.String message, Throwable cause) { - // TODO Auto-generated constructor stub - } - - public Throwable(Throwable cause) { - // TODO Auto-generated constructor stub - } -} +package java.lang; + +public class Throwable { + + public Throwable(java.lang.String message) { + // TODO Auto-generated constructor stub + } + + public Throwable() { + // TODO Auto-generated constructor stub + } + + public Throwable(java.lang.String message, Throwable cause) { + // TODO Auto-generated constructor stub + } + + public Throwable(Throwable cause) { + // TODO Auto-generated constructor stub + } +} diff --git a/JCL/converterJclMin18/src/java/lang/annotation/Annotation.java b/JCL/converterJclMin18/src/java/lang/annotation/Annotation.java index ba72aad15ec..530c272ea43 100644 --- a/JCL/converterJclMin18/src/java/lang/annotation/Annotation.java +++ b/JCL/converterJclMin18/src/java/lang/annotation/Annotation.java @@ -1,4 +1,4 @@ -package java.lang.annotation; -public interface Annotation { - -} +package java.lang.annotation; +public interface Annotation { + +} diff --git a/JCL/converterJclMin18/src/java/lang/annotation/Documented.java b/JCL/converterJclMin18/src/java/lang/annotation/Documented.java index 34494fb5f33..b70fc969617 100644 --- a/JCL/converterJclMin18/src/java/lang/annotation/Documented.java +++ b/JCL/converterJclMin18/src/java/lang/annotation/Documented.java @@ -1,12 +1,12 @@ -package java.lang.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface Documented { -} +package java.lang.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.ANNOTATION_TYPE) +public @interface Documented { +} diff --git a/JCL/converterJclMin18/src/java/lang/annotation/Inherited.java b/JCL/converterJclMin18/src/java/lang/annotation/Inherited.java index 9753e0c4127..e51219ed399 100644 --- a/JCL/converterJclMin18/src/java/lang/annotation/Inherited.java +++ b/JCL/converterJclMin18/src/java/lang/annotation/Inherited.java @@ -1,13 +1,13 @@ -package java.lang.annotation; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface Inherited { +package java.lang.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.ANNOTATION_TYPE) +public @interface Inherited { } \ No newline at end of file diff --git a/JCL/converterJclMin18/src/java/lang/annotation/Retention.java b/JCL/converterJclMin18/src/java/lang/annotation/Retention.java index 72f141758b4..9a23c8186db 100644 --- a/JCL/converterJclMin18/src/java/lang/annotation/Retention.java +++ b/JCL/converterJclMin18/src/java/lang/annotation/Retention.java @@ -1,14 +1,14 @@ -package java.lang.annotation; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface Retention { - RetentionPolicy value(); +package java.lang.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.ANNOTATION_TYPE) +public @interface Retention { + RetentionPolicy value(); } \ No newline at end of file diff --git a/JCL/converterJclMin18/src/java/lang/annotation/RetentionPolicy.java b/JCL/converterJclMin18/src/java/lang/annotation/RetentionPolicy.java index b69fa7d6544..26349b19198 100644 --- a/JCL/converterJclMin18/src/java/lang/annotation/RetentionPolicy.java +++ b/JCL/converterJclMin18/src/java/lang/annotation/RetentionPolicy.java @@ -1,6 +1,6 @@ -package java.lang.annotation; -public enum RetentionPolicy { - CLASS, - SOURCE, - RUNTIME +package java.lang.annotation; +public enum RetentionPolicy { + CLASS, + SOURCE, + RUNTIME } \ No newline at end of file diff --git a/JCL/converterJclMin18/src/java/lang/annotation/Target.java b/JCL/converterJclMin18/src/java/lang/annotation/Target.java index 239f6b1ee6a..8cd620502ac 100644 --- a/JCL/converterJclMin18/src/java/lang/annotation/Target.java +++ b/JCL/converterJclMin18/src/java/lang/annotation/Target.java @@ -1,14 +1,14 @@ -package java.lang.annotation; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface Target { - ElementType[] value(); +package java.lang.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.ANNOTATION_TYPE) +public @interface Target { + ElementType[] value(); } \ No newline at end of file diff --git a/JCL/converterJclMin18/src/java/lang/invoke/MethodHandle.java b/JCL/converterJclMin18/src/java/lang/invoke/MethodHandle.java index 789476586da..69736475bd0 100644 --- a/JCL/converterJclMin18/src/java/lang/invoke/MethodHandle.java +++ b/JCL/converterJclMin18/src/java/lang/invoke/MethodHandle.java @@ -1,39 +1,39 @@ -package java.lang.invoke; -/******************************************************************************* - * Copyright (c) 2011 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - - -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; -import java.lang.invoke.MethodType; - -public abstract class MethodHandle { - @Target(METHOD) - @Retention(RUNTIME) - @interface PolymorphicSignature { - } - - @PolymorphicSignature - public final native Object invoke(Object... args) throws Throwable; - - @PolymorphicSignature - public final native Object invokeExact(Object... args) throws Throwable; - - public native Object invokeWithArguments(Object... arguments) - throws Throwable; - - public native boolean isVarargsCollector(); - - public native MethodHandle asType(MethodType newType); +package java.lang.invoke; +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; +import java.lang.invoke.MethodType; + +public abstract class MethodHandle { + @Target(METHOD) + @Retention(RUNTIME) + @interface PolymorphicSignature { + } + + @PolymorphicSignature + public final native Object invoke(Object... args) throws Throwable; + + @PolymorphicSignature + public final native Object invokeExact(Object... args) throws Throwable; + + public native Object invokeWithArguments(Object... arguments) + throws Throwable; + + public native boolean isVarargsCollector(); + + public native MethodHandle asType(MethodType newType); } \ No newline at end of file diff --git a/JCL/converterJclMin18/src/java/lang/invoke/MethodHandles.java b/JCL/converterJclMin18/src/java/lang/invoke/MethodHandles.java index 49d9f1f87ab..582995d9d86 100644 --- a/JCL/converterJclMin18/src/java/lang/invoke/MethodHandles.java +++ b/JCL/converterJclMin18/src/java/lang/invoke/MethodHandles.java @@ -1,22 +1,22 @@ -package java.lang.invoke; -import java.lang.invoke.MethodType; - -public class MethodHandles { - public static final class Lookup { - public MethodHandle findVirtual(Class refc, String name, - MethodType type) throws NoSuchMethodException, - IllegalAccessException { - return null; - } - - public MethodHandle findStatic(Class refc, String name, - MethodType type) throws NoSuchMethodException, - IllegalAccessException { - return null; - } - } - - public static Lookup lookup() { - return null; - } -} +package java.lang.invoke; +import java.lang.invoke.MethodType; + +public class MethodHandles { + public static final class Lookup { + public MethodHandle findVirtual(Class refc, String name, + MethodType type) throws NoSuchMethodException, + IllegalAccessException { + return null; + } + + public MethodHandle findStatic(Class refc, String name, + MethodType type) throws NoSuchMethodException, + IllegalAccessException { + return null; + } + } + + public static Lookup lookup() { + return null; + } +} diff --git a/JCL/converterJclMin18/src/java/lang/invoke/MethodType.java b/JCL/converterJclMin18/src/java/lang/invoke/MethodType.java index 802a3f2c806..90a46dc8fea 100644 --- a/JCL/converterJclMin18/src/java/lang/invoke/MethodType.java +++ b/JCL/converterJclMin18/src/java/lang/invoke/MethodType.java @@ -1,17 +1,17 @@ -package java.lang.invoke; - - -public final class MethodType { - public static MethodType methodType(Class rtype, Class ptype0, - Class... ptypes) { - return null; - } - - public static MethodType methodType(Class rtype) { - return null; - } - - public static MethodType genericMethodType(int objectArgCount) { - return null; - } -} +package java.lang.invoke; + + +public final class MethodType { + public static MethodType methodType(Class rtype, Class ptype0, + Class... ptypes) { + return null; + } + + public static MethodType methodType(Class rtype) { + return null; + } + + public static MethodType genericMethodType(int objectArgCount) { + return null; + } +} diff --git a/JCL/converterJclMin18/src/java/util/Collection.java b/JCL/converterJclMin18/src/java/util/Collection.java index a40b2d29a3f..c6fb16779ce 100644 --- a/JCL/converterJclMin18/src/java/util/Collection.java +++ b/JCL/converterJclMin18/src/java/util/Collection.java @@ -1,9 +1,9 @@ -package java.util; - -public interface Collection extends Iterable { - public Iterator iterator(); - public int size(); - public T get(int index); - public boolean addAll(Collection c); - public T[] toArray(T[] o); -} +package java.util; + +public interface Collection extends Iterable { + public Iterator iterator(); + public int size(); + public T get(int index); + public boolean addAll(Collection c); + public T[] toArray(T[] o); +} diff --git a/JCL/converterJclMin18/src/java/util/Iterator.java b/JCL/converterJclMin18/src/java/util/Iterator.java index f90ee762c2f..ae53f8408e0 100644 --- a/JCL/converterJclMin18/src/java/util/Iterator.java +++ b/JCL/converterJclMin18/src/java/util/Iterator.java @@ -1,7 +1,7 @@ -package java.util; - -public interface Iterator { - boolean hasNext(); - E next(); - void remove(); -} +package java.util; + +public interface Iterator { + boolean hasNext(); + E next(); + void remove(); +} diff --git a/JCL/converterJclMin18/src/java/util/List.java b/JCL/converterJclMin18/src/java/util/List.java index 7d19bdfb1b8..4565ccb902f 100644 --- a/JCL/converterJclMin18/src/java/util/List.java +++ b/JCL/converterJclMin18/src/java/util/List.java @@ -1,4 +1,4 @@ -package java.util; - -public interface List extends Collection { -} +package java.util; + +public interface List extends Collection { +} diff --git a/JCL/converterJclMin18/src/java/util/Map.java b/JCL/converterJclMin18/src/java/util/Map.java index 574a7f816a5..f47752cfdba 100644 --- a/JCL/converterJclMin18/src/java/util/Map.java +++ b/JCL/converterJclMin18/src/java/util/Map.java @@ -1,5 +1,5 @@ -package java.util; - -public interface Map { - +package java.util; + +public interface Map { + } \ No newline at end of file diff --git a/JCL/converterJclMin19/src/java/io/Serializable.java b/JCL/converterJclMin19/src/java/io/Serializable.java index edd882d7d58..3629567396a 100644 --- a/JCL/converterJclMin19/src/java/io/Serializable.java +++ b/JCL/converterJclMin19/src/java/io/Serializable.java @@ -1,4 +1,4 @@ -package java.io; - -public interface Serializable { -} +package java.io; + +public interface Serializable { +} diff --git a/JCL/converterJclMin19/src/java/lang/CharSequence.java b/JCL/converterJclMin19/src/java/lang/CharSequence.java index b9a0d9e4176..b03fc9e823b 100644 --- a/JCL/converterJclMin19/src/java/lang/CharSequence.java +++ b/JCL/converterJclMin19/src/java/lang/CharSequence.java @@ -1,5 +1,5 @@ -package java.lang; - -public interface CharSequence { - int length(); -} +package java.lang; + +public interface CharSequence { + int length(); +} diff --git a/JCL/converterJclMin19/src/java/lang/Class.java b/JCL/converterJclMin19/src/java/lang/Class.java index a7667b98347..7d08bf1f389 100644 --- a/JCL/converterJclMin19/src/java/lang/Class.java +++ b/JCL/converterJclMin19/src/java/lang/Class.java @@ -1,4 +1,4 @@ -package java.lang; - -public class Class { -} +package java.lang; + +public class Class { +} diff --git a/JCL/converterJclMin19/src/java/lang/CloneNotSupportedException.java b/JCL/converterJclMin19/src/java/lang/CloneNotSupportedException.java index cb777dc7bac..6f05a932fab 100644 --- a/JCL/converterJclMin19/src/java/lang/CloneNotSupportedException.java +++ b/JCL/converterJclMin19/src/java/lang/CloneNotSupportedException.java @@ -1,4 +1,4 @@ -package java.lang; - -public class CloneNotSupportedException extends Exception { -} +package java.lang; + +public class CloneNotSupportedException extends Exception { +} diff --git a/JCL/converterJclMin19/src/java/lang/Comparable.java b/JCL/converterJclMin19/src/java/lang/Comparable.java index fbc6c8bac34..59fb9eddd47 100644 --- a/JCL/converterJclMin19/src/java/lang/Comparable.java +++ b/JCL/converterJclMin19/src/java/lang/Comparable.java @@ -1,4 +1,4 @@ -package java.lang; - -public interface Comparable { -} +package java.lang; + +public interface Comparable { +} diff --git a/JCL/converterJclMin19/src/java/lang/Deprecated.java b/JCL/converterJclMin19/src/java/lang/Deprecated.java index 6c73dedd0d1..5226e586c7e 100644 --- a/JCL/converterJclMin19/src/java/lang/Deprecated.java +++ b/JCL/converterJclMin19/src/java/lang/Deprecated.java @@ -1,6 +1,6 @@ -package java.lang; -import java.lang.annotation.*; -@Documented -@Retention(RetentionPolicy.RUNTIME) -public @interface Deprecated { +package java.lang; +import java.lang.annotation.*; +@Documented +@Retention(RetentionPolicy.RUNTIME) +public @interface Deprecated { } \ No newline at end of file diff --git a/JCL/converterJclMin19/src/java/lang/Enum.java b/JCL/converterJclMin19/src/java/lang/Enum.java index a510103e609..f68f11eacec 100644 --- a/JCL/converterJclMin19/src/java/lang/Enum.java +++ b/JCL/converterJclMin19/src/java/lang/Enum.java @@ -1,18 +1,18 @@ -package java.lang; - -public abstract class Enum> implements Comparable, java.io.Serializable { - private static final long serialVersionUID = 2L; - - protected Enum(String name, int ordinal) { - } - public final String name() { - return null; - } - public final int ordinal() { - return 0; - } - public static > T valueOf(Class enumClass, - String name) { - return null; - } -} +package java.lang; + +public abstract class Enum> implements Comparable, java.io.Serializable { + private static final long serialVersionUID = 2L; + + protected Enum(String name, int ordinal) { + } + public final String name() { + return null; + } + public final int ordinal() { + return 0; + } + public static > T valueOf(Class enumClass, + String name) { + return null; + } +} diff --git a/JCL/converterJclMin19/src/java/lang/Error.java b/JCL/converterJclMin19/src/java/lang/Error.java index 9a446d53249..820d8c62226 100644 --- a/JCL/converterJclMin19/src/java/lang/Error.java +++ b/JCL/converterJclMin19/src/java/lang/Error.java @@ -1,16 +1,16 @@ -package java.lang; - -public class Error extends Throwable { - - public Error(java.lang.String s) { - // TODO Auto-generated constructor stub - } - - public Error(java.lang.String s, java.lang.Throwable cause) { - // TODO Auto-generated constructor stub - } - - public Error() { - // TODO Auto-generated constructor stub - } -} +package java.lang; + +public class Error extends Throwable { + + public Error(java.lang.String s) { + // TODO Auto-generated constructor stub + } + + public Error(java.lang.String s, java.lang.Throwable cause) { + // TODO Auto-generated constructor stub + } + + public Error() { + // TODO Auto-generated constructor stub + } +} diff --git a/JCL/converterJclMin19/src/java/lang/Exception.java b/JCL/converterJclMin19/src/java/lang/Exception.java index 0adef36baff..88b222a9c06 100644 --- a/JCL/converterJclMin19/src/java/lang/Exception.java +++ b/JCL/converterJclMin19/src/java/lang/Exception.java @@ -1,19 +1,19 @@ -package java.lang; - -public class Exception extends Throwable { - public Exception() { - super(); - } - - public Exception(String message) { - super(message); - } - - public Exception(String message, Throwable cause) { - super(message, cause); - } - - public Exception(Throwable cause) { - super(cause); - } -} +package java.lang; + +public class Exception extends Throwable { + public Exception() { + super(); + } + + public Exception(String message) { + super(message); + } + + public Exception(String message, Throwable cause) { + super(message, cause); + } + + public Exception(Throwable cause) { + super(cause); + } +} diff --git a/JCL/converterJclMin19/src/java/lang/IllegalAccessException.java b/JCL/converterJclMin19/src/java/lang/IllegalAccessException.java index 814649067f6..0d13e1e0571 100644 --- a/JCL/converterJclMin19/src/java/lang/IllegalAccessException.java +++ b/JCL/converterJclMin19/src/java/lang/IllegalAccessException.java @@ -1,5 +1,5 @@ -package java.lang; - -public class IllegalAccessException extends RuntimeException { - -} +package java.lang; + +public class IllegalAccessException extends RuntimeException { + +} diff --git a/JCL/converterJclMin19/src/java/lang/IllegalMonitorStateException.java b/JCL/converterJclMin19/src/java/lang/IllegalMonitorStateException.java index e173f133abe..1f67418128c 100644 --- a/JCL/converterJclMin19/src/java/lang/IllegalMonitorStateException.java +++ b/JCL/converterJclMin19/src/java/lang/IllegalMonitorStateException.java @@ -1,4 +1,4 @@ -package java.lang; - -public class IllegalMonitorStateException extends RuntimeException { -} +package java.lang; + +public class IllegalMonitorStateException extends RuntimeException { +} diff --git a/JCL/converterJclMin19/src/java/lang/InterruptedException.java b/JCL/converterJclMin19/src/java/lang/InterruptedException.java index e2e84ba0bc2..93b236c4210 100644 --- a/JCL/converterJclMin19/src/java/lang/InterruptedException.java +++ b/JCL/converterJclMin19/src/java/lang/InterruptedException.java @@ -1,4 +1,4 @@ -package java.lang; - -public class InterruptedException extends Exception { -} +package java.lang; + +public class InterruptedException extends Exception { +} diff --git a/JCL/converterJclMin19/src/java/lang/NoSuchMethodException.java b/JCL/converterJclMin19/src/java/lang/NoSuchMethodException.java index b8c5bce7a5b..3dd142bdd33 100644 --- a/JCL/converterJclMin19/src/java/lang/NoSuchMethodException.java +++ b/JCL/converterJclMin19/src/java/lang/NoSuchMethodException.java @@ -1,5 +1,5 @@ -package java.lang; - -public class NoSuchMethodException extends RuntimeException { - -} +package java.lang; + +public class NoSuchMethodException extends RuntimeException { + +} diff --git a/JCL/converterJclMin19/src/java/lang/Object.java b/JCL/converterJclMin19/src/java/lang/Object.java index eb50899e5ba..71ddb4ff834 100644 --- a/JCL/converterJclMin19/src/java/lang/Object.java +++ b/JCL/converterJclMin19/src/java/lang/Object.java @@ -1,34 +1,34 @@ -package java.lang; - -public class Object { - -public Object() { -} -protected Object clone() throws CloneNotSupportedException { - return null; -} -public boolean equals (Object obj) { - return false; -} -protected void finalize () throws Throwable { -} -public final Class getClass() { - return null; -} -public int hashCode() { - return -1; -} -public final void notify() throws IllegalMonitorStateException { -} -public final void notifyAll() throws IllegalMonitorStateException { -} -public String toString () { - return null; -} -public final void wait () throws IllegalMonitorStateException, InterruptedException { -} -public final void wait (long millis) throws IllegalMonitorStateException, InterruptedException { -} -public final void wait (long millis, int nanos) throws IllegalMonitorStateException, InterruptedException { -} -} +package java.lang; + +public class Object { + +public Object() { +} +protected Object clone() throws CloneNotSupportedException { + return null; +} +public boolean equals (Object obj) { + return false; +} +protected void finalize () throws Throwable { +} +public final Class getClass() { + return null; +} +public int hashCode() { + return -1; +} +public final void notify() throws IllegalMonitorStateException { +} +public final void notifyAll() throws IllegalMonitorStateException { +} +public String toString () { + return null; +} +public final void wait () throws IllegalMonitorStateException, InterruptedException { +} +public final void wait (long millis) throws IllegalMonitorStateException, InterruptedException { +} +public final void wait (long millis, int nanos) throws IllegalMonitorStateException, InterruptedException { +} +} diff --git a/JCL/converterJclMin19/src/java/lang/RuntimeException.java b/JCL/converterJclMin19/src/java/lang/RuntimeException.java index 80dc1dbd34e..3d94712d7f8 100644 --- a/JCL/converterJclMin19/src/java/lang/RuntimeException.java +++ b/JCL/converterJclMin19/src/java/lang/RuntimeException.java @@ -1,12 +1,12 @@ -package java.lang; - -public class RuntimeException extends Exception { - - public RuntimeException(java.lang.String s) { - // TODO Auto-generated constructor stub - } - - public RuntimeException() { - // TODO Auto-generated constructor stub - } -} +package java.lang; + +public class RuntimeException extends Exception { + + public RuntimeException(java.lang.String s) { + // TODO Auto-generated constructor stub + } + + public RuntimeException() { + // TODO Auto-generated constructor stub + } +} diff --git a/JCL/converterJclMin19/src/java/lang/String.java b/JCL/converterJclMin19/src/java/lang/String.java index ba6bf08bf4f..64f759b78be 100644 --- a/JCL/converterJclMin19/src/java/lang/String.java +++ b/JCL/converterJclMin19/src/java/lang/String.java @@ -1,8 +1,8 @@ -package java.lang; - -public class String implements CharSequence { - public int length() { return 0; } - public int codePointAt(int index) { - return 0; - } -} +package java.lang; + +public class String implements CharSequence { + public int length() { return 0; } + public int codePointAt(int index) { + return 0; + } +} diff --git a/JCL/converterJclMin19/src/java/lang/Throwable.java b/JCL/converterJclMin19/src/java/lang/Throwable.java index 2488269bebc..73ab84b6950 100644 --- a/JCL/converterJclMin19/src/java/lang/Throwable.java +++ b/JCL/converterJclMin19/src/java/lang/Throwable.java @@ -1,20 +1,20 @@ -package java.lang; - -public class Throwable { - - public Throwable(java.lang.String message) { - // TODO Auto-generated constructor stub - } - - public Throwable() { - // TODO Auto-generated constructor stub - } - - public Throwable(java.lang.String message, Throwable cause) { - // TODO Auto-generated constructor stub - } - - public Throwable(Throwable cause) { - // TODO Auto-generated constructor stub - } -} +package java.lang; + +public class Throwable { + + public Throwable(java.lang.String message) { + // TODO Auto-generated constructor stub + } + + public Throwable() { + // TODO Auto-generated constructor stub + } + + public Throwable(java.lang.String message, Throwable cause) { + // TODO Auto-generated constructor stub + } + + public Throwable(Throwable cause) { + // TODO Auto-generated constructor stub + } +} diff --git a/JCL/converterJclMin19/src/java/lang/annotation/Annotation.java b/JCL/converterJclMin19/src/java/lang/annotation/Annotation.java index ba72aad15ec..530c272ea43 100644 --- a/JCL/converterJclMin19/src/java/lang/annotation/Annotation.java +++ b/JCL/converterJclMin19/src/java/lang/annotation/Annotation.java @@ -1,4 +1,4 @@ -package java.lang.annotation; -public interface Annotation { - -} +package java.lang.annotation; +public interface Annotation { + +} diff --git a/JCL/converterJclMin19/src/java/lang/annotation/Documented.java b/JCL/converterJclMin19/src/java/lang/annotation/Documented.java index 34494fb5f33..b70fc969617 100644 --- a/JCL/converterJclMin19/src/java/lang/annotation/Documented.java +++ b/JCL/converterJclMin19/src/java/lang/annotation/Documented.java @@ -1,12 +1,12 @@ -package java.lang.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface Documented { -} +package java.lang.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.ANNOTATION_TYPE) +public @interface Documented { +} diff --git a/JCL/converterJclMin19/src/java/lang/annotation/Inherited.java b/JCL/converterJclMin19/src/java/lang/annotation/Inherited.java index 9753e0c4127..e51219ed399 100644 --- a/JCL/converterJclMin19/src/java/lang/annotation/Inherited.java +++ b/JCL/converterJclMin19/src/java/lang/annotation/Inherited.java @@ -1,13 +1,13 @@ -package java.lang.annotation; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface Inherited { +package java.lang.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.ANNOTATION_TYPE) +public @interface Inherited { } \ No newline at end of file diff --git a/JCL/converterJclMin19/src/java/lang/annotation/Retention.java b/JCL/converterJclMin19/src/java/lang/annotation/Retention.java index 72f141758b4..9a23c8186db 100644 --- a/JCL/converterJclMin19/src/java/lang/annotation/Retention.java +++ b/JCL/converterJclMin19/src/java/lang/annotation/Retention.java @@ -1,14 +1,14 @@ -package java.lang.annotation; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface Retention { - RetentionPolicy value(); +package java.lang.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.ANNOTATION_TYPE) +public @interface Retention { + RetentionPolicy value(); } \ No newline at end of file diff --git a/JCL/converterJclMin19/src/java/lang/annotation/RetentionPolicy.java b/JCL/converterJclMin19/src/java/lang/annotation/RetentionPolicy.java index b69fa7d6544..26349b19198 100644 --- a/JCL/converterJclMin19/src/java/lang/annotation/RetentionPolicy.java +++ b/JCL/converterJclMin19/src/java/lang/annotation/RetentionPolicy.java @@ -1,6 +1,6 @@ -package java.lang.annotation; -public enum RetentionPolicy { - CLASS, - SOURCE, - RUNTIME +package java.lang.annotation; +public enum RetentionPolicy { + CLASS, + SOURCE, + RUNTIME } \ No newline at end of file diff --git a/JCL/converterJclMin19/src/java/lang/annotation/Target.java b/JCL/converterJclMin19/src/java/lang/annotation/Target.java index 239f6b1ee6a..8cd620502ac 100644 --- a/JCL/converterJclMin19/src/java/lang/annotation/Target.java +++ b/JCL/converterJclMin19/src/java/lang/annotation/Target.java @@ -1,14 +1,14 @@ -package java.lang.annotation; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface Target { - ElementType[] value(); +package java.lang.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.ANNOTATION_TYPE) +public @interface Target { + ElementType[] value(); } \ No newline at end of file diff --git a/JCL/converterJclMin19/src/java/lang/invoke/MethodHandle.java b/JCL/converterJclMin19/src/java/lang/invoke/MethodHandle.java index 789476586da..69736475bd0 100644 --- a/JCL/converterJclMin19/src/java/lang/invoke/MethodHandle.java +++ b/JCL/converterJclMin19/src/java/lang/invoke/MethodHandle.java @@ -1,39 +1,39 @@ -package java.lang.invoke; -/******************************************************************************* - * Copyright (c) 2011 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - - -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; -import java.lang.invoke.MethodType; - -public abstract class MethodHandle { - @Target(METHOD) - @Retention(RUNTIME) - @interface PolymorphicSignature { - } - - @PolymorphicSignature - public final native Object invoke(Object... args) throws Throwable; - - @PolymorphicSignature - public final native Object invokeExact(Object... args) throws Throwable; - - public native Object invokeWithArguments(Object... arguments) - throws Throwable; - - public native boolean isVarargsCollector(); - - public native MethodHandle asType(MethodType newType); +package java.lang.invoke; +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; +import java.lang.invoke.MethodType; + +public abstract class MethodHandle { + @Target(METHOD) + @Retention(RUNTIME) + @interface PolymorphicSignature { + } + + @PolymorphicSignature + public final native Object invoke(Object... args) throws Throwable; + + @PolymorphicSignature + public final native Object invokeExact(Object... args) throws Throwable; + + public native Object invokeWithArguments(Object... arguments) + throws Throwable; + + public native boolean isVarargsCollector(); + + public native MethodHandle asType(MethodType newType); } \ No newline at end of file diff --git a/JCL/converterJclMin19/src/java/lang/invoke/MethodHandles.java b/JCL/converterJclMin19/src/java/lang/invoke/MethodHandles.java index 49d9f1f87ab..582995d9d86 100644 --- a/JCL/converterJclMin19/src/java/lang/invoke/MethodHandles.java +++ b/JCL/converterJclMin19/src/java/lang/invoke/MethodHandles.java @@ -1,22 +1,22 @@ -package java.lang.invoke; -import java.lang.invoke.MethodType; - -public class MethodHandles { - public static final class Lookup { - public MethodHandle findVirtual(Class refc, String name, - MethodType type) throws NoSuchMethodException, - IllegalAccessException { - return null; - } - - public MethodHandle findStatic(Class refc, String name, - MethodType type) throws NoSuchMethodException, - IllegalAccessException { - return null; - } - } - - public static Lookup lookup() { - return null; - } -} +package java.lang.invoke; +import java.lang.invoke.MethodType; + +public class MethodHandles { + public static final class Lookup { + public MethodHandle findVirtual(Class refc, String name, + MethodType type) throws NoSuchMethodException, + IllegalAccessException { + return null; + } + + public MethodHandle findStatic(Class refc, String name, + MethodType type) throws NoSuchMethodException, + IllegalAccessException { + return null; + } + } + + public static Lookup lookup() { + return null; + } +} diff --git a/JCL/converterJclMin19/src/java/lang/invoke/MethodType.java b/JCL/converterJclMin19/src/java/lang/invoke/MethodType.java index 802a3f2c806..90a46dc8fea 100644 --- a/JCL/converterJclMin19/src/java/lang/invoke/MethodType.java +++ b/JCL/converterJclMin19/src/java/lang/invoke/MethodType.java @@ -1,17 +1,17 @@ -package java.lang.invoke; - - -public final class MethodType { - public static MethodType methodType(Class rtype, Class ptype0, - Class... ptypes) { - return null; - } - - public static MethodType methodType(Class rtype) { - return null; - } - - public static MethodType genericMethodType(int objectArgCount) { - return null; - } -} +package java.lang.invoke; + + +public final class MethodType { + public static MethodType methodType(Class rtype, Class ptype0, + Class... ptypes) { + return null; + } + + public static MethodType methodType(Class rtype) { + return null; + } + + public static MethodType genericMethodType(int objectArgCount) { + return null; + } +} diff --git a/JCL/converterJclMin19/src/java/util/Collection.java b/JCL/converterJclMin19/src/java/util/Collection.java index a40b2d29a3f..c6fb16779ce 100644 --- a/JCL/converterJclMin19/src/java/util/Collection.java +++ b/JCL/converterJclMin19/src/java/util/Collection.java @@ -1,9 +1,9 @@ -package java.util; - -public interface Collection extends Iterable { - public Iterator iterator(); - public int size(); - public T get(int index); - public boolean addAll(Collection c); - public T[] toArray(T[] o); -} +package java.util; + +public interface Collection extends Iterable { + public Iterator iterator(); + public int size(); + public T get(int index); + public boolean addAll(Collection c); + public T[] toArray(T[] o); +} diff --git a/JCL/converterJclMin19/src/java/util/Iterator.java b/JCL/converterJclMin19/src/java/util/Iterator.java index f90ee762c2f..ae53f8408e0 100644 --- a/JCL/converterJclMin19/src/java/util/Iterator.java +++ b/JCL/converterJclMin19/src/java/util/Iterator.java @@ -1,7 +1,7 @@ -package java.util; - -public interface Iterator { - boolean hasNext(); - E next(); - void remove(); -} +package java.util; + +public interface Iterator { + boolean hasNext(); + E next(); + void remove(); +} diff --git a/JCL/converterJclMin19/src/java/util/List.java b/JCL/converterJclMin19/src/java/util/List.java index 7d19bdfb1b8..4565ccb902f 100644 --- a/JCL/converterJclMin19/src/java/util/List.java +++ b/JCL/converterJclMin19/src/java/util/List.java @@ -1,4 +1,4 @@ -package java.util; - -public interface List extends Collection { -} +package java.util; + +public interface List extends Collection { +} diff --git a/JCL/converterJclMin19/src/java/util/Map.java b/JCL/converterJclMin19/src/java/util/Map.java index 574a7f816a5..f47752cfdba 100644 --- a/JCL/converterJclMin19/src/java/util/Map.java +++ b/JCL/converterJclMin19/src/java/util/Map.java @@ -1,5 +1,5 @@ -package java.util; - -public interface Map { - +package java.util; + +public interface Map { + } \ No newline at end of file diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated18Test.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated18Test.java index 1072a93d3cc..33c07050726 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated18Test.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated18Test.java @@ -72,7 +72,7 @@ public void testGH1370() { public class X { @Deprecated static void deprecatedMethod(Object o) {} - } + } """, "Y.java", """ @@ -89,7 +89,7 @@ void callDeprecated2() { List.of().forEach(X::deprecatedMethod); List.of().forEach(o -> X.deprecatedMethod(o)); } - } + } """, }, """ @@ -108,7 +108,7 @@ The method deprecatedMethod(Object) from the type X is deprecated List.of().forEach(o -> X.deprecatedMethod(o)); ^^^^^^^^^^^^^^^^^^^ The method deprecatedMethod(Object) from the type X is deprecated - ---------- + ---------- """, null, true, diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchPatternTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchPatternTest.java index d9d2efe3d44..6dbae7389a9 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchPatternTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchPatternTest.java @@ -4519,7 +4519,7 @@ public void testBug578553_1() { case (Long l) when l.toString().equals("0") -> { ^^ Syntax error on token "->", ; expected - ---------- + ---------- """); } public void testBug578553_2() { @@ -4571,7 +4571,7 @@ public void testBug578553_2() { case Long l1 when l1.toString().equals(l1.toString()) -> { ^^^^ Syntax error on token "when", , expected - ---------- + ---------- """); } public void testBug578553_3() { @@ -4620,7 +4620,7 @@ public void testBug578553_3() { case Long l1 when l.toString().equals(l1.toString()) -> { ^^^^ Syntax error on token "when", , expected - ---------- + ---------- """); } public void testBug578553_4() { diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java index 2adfa06eeb3..67631ae615a 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java @@ -1,16262 +1,16262 @@ -/******************************************************************************* - * Copyright (c) 2000, 2022 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - * Brock Janiczak - Contribution for bug 150741 - * Ray V. (voidstar@gmail.com) - Contribution for bug 282988 - * Mateusz Matela - [formatter] Formatter does not format Java code correctly, especially when max line width is set - https://bugs.eclipse.org/303519 - *******************************************************************************/ -package org.eclipse.jdt.core.tests.formatter; - -import java.io.BufferedInputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Map; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import junit.framework.Test; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceDescription; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.ToolFactory; -import org.eclipse.jdt.core.compiler.CharOperation; -import org.eclipse.jdt.core.dom.ASTNode; -import org.eclipse.jdt.core.formatter.CodeFormatter; -import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; -import org.eclipse.jdt.core.formatter.IndentManipulation; -import org.eclipse.jdt.core.tests.model.AbstractJavaModelTests; -import org.eclipse.jdt.core.tests.util.Util; -import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; -import org.eclipse.jdt.internal.formatter.DefaultCodeFormatter; -import org.eclipse.jdt.internal.formatter.DefaultCodeFormatterOptions; -import org.eclipse.jdt.internal.formatter.DefaultCodeFormatterOptions.Alignment; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.Region; -import org.eclipse.text.edits.TextEdit; - -@SuppressWarnings({"rawtypes", "unchecked"}) -public class FormatterRegressionTests extends AbstractJavaModelTests { - - protected static IJavaProject JAVA_PROJECT; - - public static final int UNKNOWN_KIND = 0; - public static final String IN = "_in"; - public static final String OUT = "_out"; - public static final boolean DEBUG = false; - static final String LINE_SEPARATOR = System.getProperty("line.separator"); - private long time; - - DefaultCodeFormatterOptions formatterPrefs; - Map formatterOptions; - - static { -// TESTS_NUMBERS = new int[] { 783 }; -// TESTS_RANGE = new int[] { 734, -1 }; -// TESTS_NAMES = new String[] {"testBug432593"}; - } - public static Test suite() { - return buildModelTestSuite(FormatterRegressionTests.class); - } - - public FormatterRegressionTests(String name) { - super(name); - } - - /** - * Helper method for tests that require a certain compiler compliance level. - * @param level use one of the {@code CompilerOptions.VERSION_***} constants - */ - protected void setComplianceLevel(String level) { - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, level); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, level); - this.formatterOptions.put(CompilerOptions.OPTION_Source, level); - } - - /* - * helper function for tests that are compatible with earlier page width - */ - protected void setPageWidth80() { - this.formatterPrefs.page_width = 80; - } - - /* - * helper function for tests that are compatible with earlier page width - */ - protected void setPageWidth80(DefaultCodeFormatterOptions preferences) { - preferences.page_width = 80; - } - - /* - * helper function for tests that are compatible with earlier page width - */ - private void setFormatterOptions80() { - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, Integer.toString(80)); - } - - /* - * helper function for tests that are compatible with earlier Javadoc formatting rules - */ - protected void useOldJavadocTagsFormatting() { - this.formatterPrefs.comment_insert_new_line_for_parameter = true; - this.formatterPrefs.comment_align_tags_descriptions_grouped = false; - this.formatterPrefs.comment_indent_root_tags = true; - this.formatterPrefs.comment_indent_parameter_description = true; - } - - /** - * Helper function for tests that are expect comment width counted from the - * beginning of the line, not from comment's starting position. - */ - protected void useOldCommentWidthCounting() { - this.formatterPrefs.comment_count_line_length_from_starting_position = false; - } - - /** - * Helper function for old tests that are expect comment line comments - * on first column to be formatted. - */ - protected void setFormatLineCommentOnFirstColumn() { - this.formatterPrefs.comment_format_line_comment_starting_on_first_column = true; - } - - private String getResource(String packageName, String resourceName) { - IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); - IResource resource = workspaceRoot.findMember(new Path("/Formatter/" + packageName + "/" + resourceName)); - assertNotNull("No resource found", resource); - return resource.getLocation().toOSString(); - } - - private String getZipEntryContents(String fileName, String zipEntryName) { - ZipFile zipFile = null; - BufferedInputStream inputStream = null; - try { - zipFile = new ZipFile(fileName); - ZipEntry zipEntry = zipFile.getEntry(zipEntryName); - inputStream = new BufferedInputStream(zipFile.getInputStream(zipEntry)); - return new String(org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsCharArray(inputStream, null)); - } catch (IOException e) { - } finally { - try { - if (inputStream != null) { - inputStream.close(); - } - if (zipFile != null) { - zipFile.close(); - } - } catch (IOException e1) { - // Do nothing - } - } - return null; - } - - /* - public String getSourceWorkspacePath() { - return getPluginDirectoryPath() + java.io.File.separator + "workspace"; - } - */ - - String runFormatter(CodeFormatter codeFormatter, String source, int kind, int indentationLevel, int offset, int length, String lineSeparator, boolean repeat) { -// long time = System.currentTimeMillis(); - TextEdit edit = codeFormatter.format(kind, source, offset, length, indentationLevel, lineSeparator);//$NON-NLS-1$ -// System.out.println((System.currentTimeMillis() - time) + " ms"); - if (edit == null) return null; -// System.out.println(edit.getChildrenSize() + " edits"); - String result = org.eclipse.jdt.internal.core.util.Util.editedString(source, edit); - - if (repeat && length == source.length()) { -// time = System.currentTimeMillis(); - edit = codeFormatter.format(kind, result, 0, result.length(), indentationLevel, lineSeparator);//$NON-NLS-1$ -// System.out.println((System.currentTimeMillis() - time) + " ms"); - if (edit == null) return null; -// assertEquals("Should not have edits", 0, edit.getChildren().length); - final String result2 = org.eclipse.jdt.internal.core.util.Util.editedString(result, edit); - if (!result.equals(result2)) { - assertSourceEquals("Second formatting is different from first one!", Util.convertToIndependantLineDelimiter(result), Util.convertToIndependantLineDelimiter(result2)); - } - } - return result; - } - - String runFormatter(CodeFormatter codeFormatter, String source, int kind, int indentationLevel, IRegion[] regions, String lineSeparator) { -// long time = System.currentTimeMillis(); - TextEdit edit = codeFormatter.format(kind, source, regions, indentationLevel, lineSeparator);//$NON-NLS-1$ -// System.out.println((System.currentTimeMillis() - time) + " ms"); - if (edit == null) return null; - - return org.eclipse.jdt.internal.core.util.Util.editedString(source, edit); - } - - /** - * Init formatter preferences with Eclipse default settings. - */ - @Override - protected void setUp() throws Exception { - super.setUp(); - this.formatterPrefs = DefaultCodeFormatterOptions.getEclipseDefaultSettings(); - if (JAVA_PROJECT != null) { - this.formatterOptions = JAVA_PROJECT.getOptions(true); - } - } - - /** - * Create project and set the jar placeholder. - */ - @Override - public void setUpSuite() throws Exception { - // ensure autobuilding is turned off - IWorkspaceDescription description = getWorkspace().getDescription(); - if (description.isAutoBuilding()) { - description.setAutoBuilding(false); - getWorkspace().setDescription(description); - } - - if (JAVA_PROJECT == null) { - JAVA_PROJECT = setUpJavaProject("Formatter"); //$NON-NLS-1$ - } - - if (DEBUG) { - this.time = System.currentTimeMillis(); - } - } - - /** - * Reset the jar placeholder and delete project. - */ - @Override - public void tearDownSuite() throws Exception { - deleteProject(JAVA_PROJECT); //$NON-NLS-1$ - JAVA_PROJECT = null; - if (DEBUG) { - System.out.println("Time spent = " + (System.currentTimeMillis() - this.time));//$NON-NLS-1$ - } - super.tearDownSuite(); - } - - private String getIn(String compilationUnitName) { - assertNotNull(compilationUnitName); - int dotIndex = compilationUnitName.indexOf('.'); - assertTrue(dotIndex != -1); - return compilationUnitName.substring(0, dotIndex) + IN + compilationUnitName.substring(dotIndex); - } - - private String getOut(String compilationUnitName) { - assertNotNull(compilationUnitName); - int dotIndex = compilationUnitName.indexOf('.'); - assertTrue(dotIndex != -1); - return compilationUnitName.substring(0, dotIndex) + OUT + compilationUnitName.substring(dotIndex); - } - - void assertLineEquals(String actualContents, String originalSource, String expectedContents, boolean checkNull) { - if (actualContents == null) { - assertTrue("actualContents is null", checkNull); - assertEquals(expectedContents, originalSource); - return; - } - assertSourceEquals("Different number of length", Util.convertToIndependantLineDelimiter(expectedContents), actualContents); - } - - void assertLineEquals(String actualContents, String originalSource, String expectedContents) { - String outputSource = expectedContents == null ? originalSource : expectedContents; - assertLineEquals(actualContents, originalSource, outputSource, false /* do not check null */); - } - - DefaultCodeFormatter codeFormatter() { - if (this.formatterOptions == null) { - this.formatterOptions = JAVA_PROJECT.getOptions(true); - } - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(this.formatterPrefs, this.formatterOptions); - return codeFormatter; - } - - void formatSource(String source) { - // expect unchanged source after formatting - formatSource(source, source); - } - - void formatSource(String source, String formattedOutput) { - formatSource(source, formattedOutput, CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS, 0, true /*repeat formatting twice*/); - } - - void formatSource(String source, String formattedOutput, int kind) { - formatSource(source, formattedOutput, kind, 0, true /*repeat formatting twice*/); - } - - void formatSource(String source, String formattedOutput, boolean repeat) { - formatSource(source, formattedOutput, CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS, 0, repeat); - } - - void formatSource(String source, String formattedOutput, int kind, int indentationLevel, boolean repeat) { - int regionStart = source.indexOf("[#"); - if (regionStart != -1) { - ArrayList regions = new ArrayList<>(); - int start = 0; - int delta = 0; - StringBuilder buffer = new StringBuilder(); - while (regionStart != -1) { - buffer.append(source.substring(start, regionStart)); - int regionEnd = source.indexOf("#]", regionStart+2); - buffer.append(source.substring(regionStart+2, regionEnd)); - regions.add(new Region(regionStart-delta, regionEnd-(regionStart+2))); - delta += 4; - start = regionEnd + 2; - regionStart = source.indexOf("[#", start); - } - buffer.append(source.substring(start, source.length())); - String newSource = buffer.toString(); - String result; - if (regions.size() == 1) { - // Use offset and length until bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=233967 is fixed - result = runFormatter(codeFormatter(), newSource, kind, indentationLevel, regions.get(0).getOffset(), regions.get(0).getLength(), LINE_SEPARATOR, repeat); - } else { - IRegion[] regionsArray = regions.toArray(new IRegion[regions.size()]); - result = runFormatter(codeFormatter(), newSource, kind, indentationLevel, regionsArray, LINE_SEPARATOR); - } - assertLineEquals(result, newSource, formattedOutput); - } else { - formatSource(source, formattedOutput, kind, indentationLevel, 0, -1, null, repeat); - } - } - - void formatSource(String source, String formattedOutput, int kind, int indentationLevel, int offset, int length, String lineSeparator, boolean repeat) { - DefaultCodeFormatter codeFormatter = codeFormatter(); - String result; - if (length == -1) { - result = runFormatter(codeFormatter, source, kind, indentationLevel, offset, source.length(), lineSeparator, repeat); - } else { - result = runFormatter(codeFormatter, source, kind, indentationLevel, offset, length, lineSeparator, repeat); - } - if (lineSeparator == null) { - assertLineEquals(result, source, formattedOutput); - } else { - // Do not convert line delimiter while comparing result when a specific one is specified - assertNotNull("Error(s) occured while formatting", result); - String outputSource = formattedOutput == null ? source : formattedOutput; - assertSourceEquals("Different number of length", outputSource, result, false/*do not convert line delimiter*/); - } - } - - void formatSourceInWorkspace(String packageName, String inputCuName, String outputCuName) throws JavaModelException { - String input = getCompilationUnit("Formatter", "", packageName, inputCuName).getSource(); - formatSource(input, getCompilationUnit("Formatter", "", packageName, outputCuName).getSource()); - } - - - private void runTest(String packageName, String compilationUnitName) { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, packageName, compilationUnitName, CodeFormatter.K_COMPILATION_UNIT, 0); - } - - private void runTest(CodeFormatter codeFormatter, String packageName, String compilationUnitName) { - runTest(codeFormatter, packageName, compilationUnitName, CodeFormatter.K_COMPILATION_UNIT, 0); - } - - private void runTest(String packageName, String compilationUnitName, int kind) { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, packageName, compilationUnitName, kind, 0); - } - - private void runTest(CodeFormatter codeFormatter, String packageName, String compilationUnitName, int kind) { - runTest(codeFormatter, packageName, compilationUnitName, kind, 0, false, 0, -1); - } - - private void runTest(CodeFormatter codeFormatter, String packageName, String compilationUnitName, int kind, boolean checkNull) { - runTest(codeFormatter, packageName, compilationUnitName, kind, 0, checkNull, 0, -1); - } - - private void runTest(CodeFormatter codeFormatter, String packageName, String compilationUnitName, int kind, int indentationLevel) { - runTest(codeFormatter, packageName, compilationUnitName, kind, indentationLevel, false, 0, -1); - } - private void runTest(CodeFormatter codeFormatter, String packageName, String compilationUnitName, int kind, int indentationLevel, boolean checkNull, int offset, int length) { - runTest(codeFormatter, packageName, compilationUnitName, kind, indentationLevel, checkNull, offset, length, null); - } - - private void runTest(String input, String output, CodeFormatter codeFormatter, int kind, int indentationLevel, boolean checkNull, int offset, int length, String lineSeparator) { - String result; - if (length == -1) { - result = runFormatter(codeFormatter, input, kind, indentationLevel, offset, input.length(), lineSeparator, true); - } else { - result = runFormatter(codeFormatter, input, kind, indentationLevel, offset, length, lineSeparator, true); - } - assertLineEquals(result, input, output, checkNull); - } - - private void runTest(String source, String expectedResult, CodeFormatter codeFormatter, int kind, int indentationLevel, boolean checkNull, int offset, int length) { - String result; - if (length == -1) { - result = runFormatter(codeFormatter, source, kind, indentationLevel, offset, source.length(), null, true); - } else { - result = runFormatter(codeFormatter, source, kind, indentationLevel, offset, length, null, true); - } - assertLineEquals(result, source, expectedResult, checkNull); - } - - private void runTest(CodeFormatter codeFormatter, String packageName, String compilationUnitName, int kind, int indentationLevel, boolean checkNull, int offset, int length, String lineSeparator) { - try { - ICompilationUnit sourceUnit = getCompilationUnit("Formatter" , "", packageName, getIn(compilationUnitName)); //$NON-NLS-1$ //$NON-NLS-2$ - String source = sourceUnit.getSource(); - assertNotNull(source); - ICompilationUnit outputUnit = getCompilationUnit("Formatter" , "", packageName, getOut(compilationUnitName)); //$NON-NLS-1$ //$NON-NLS-2$ - assertNotNull(outputUnit); - String result; - if (length == -1) { - result = runFormatter(codeFormatter, source, kind, indentationLevel, offset, source.length(), lineSeparator, true); - } else { - result = runFormatter(codeFormatter, source, kind, indentationLevel, offset, length, lineSeparator, true); - } - assertLineEquals(result, source, outputUnit.getSource(), checkNull); - } catch (JavaModelException e) { - e.printStackTrace(); - assertTrue(false); - } - } - - private void runTest(CodeFormatter codeFormatter, String packageName, String compilationUnitName, int kind, int indentationLevel, boolean checkNull, IRegion[] regions, String lineSeparator) { - try { - ICompilationUnit sourceUnit = getCompilationUnit("Formatter" , "", packageName, getIn(compilationUnitName)); //$NON-NLS-1$ //$NON-NLS-2$ - String s = sourceUnit.getSource(); - assertNotNull(s); - ICompilationUnit outputUnit = getCompilationUnit("Formatter" , "", packageName, getOut(compilationUnitName)); //$NON-NLS-1$ //$NON-NLS-2$ - assertNotNull(outputUnit); - setPageWidth80(); - String result= runFormatter(codeFormatter, s, kind, indentationLevel, regions, lineSeparator); - assertLineEquals(result, s, outputUnit.getSource(), checkNull); - } catch (JavaModelException e) { - e.printStackTrace(); - assertTrue(false); - } - } - - String getSource(ASTNode astNode, char[] source) { - String result = new String(CharOperation.subarray(source, astNode.getStartPosition() + 1, astNode.getStartPosition() + astNode.getLength() - 1)); - if (result.endsWith("\\n")) { - return result.substring(0, result.length() - 2) + LINE_SEPARATOR; - } - return result; - } - - public void test001() { - runTest("test001", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - public void test002() { - runTest("test002", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test003() { - runTest("test003", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test004() { - runTest("test004", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - public void test005() { - runTest("test005", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test006() { - runTest("test006", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test007() { - runTest("test007", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test008() { - runTest("test008", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test009() { - runTest("test009", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test010() { - runTest("test010", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test011() { - runTest("test011", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test012() { - runTest("test012", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test013() { - runTest("test013", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test014() { - runTest("test014", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test015() { - runTest("test015", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test016() { - runTest("test016", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test017() { - runTest("test017", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test018() { - runTest("test018", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test019() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test019", "A_1.java");//$NON-NLS-1$ //$NON-NLS-2$ - - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test019", "A_2.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test020() { - runTest("test020", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test021() { - runTest("test021", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test022() { - runTest("test022", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test023() { - runTest("test023", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test024() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - setPageWidth80(preferences); - preferences.keep_simple_if_on_one_line = true; - preferences.keep_then_statement_on_same_line = true; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test024", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test025() { - runTest("test025", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test026() { - runTest("test026", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test026b() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.wrap_outer_expressions_when_nested = false; - setPageWidth80(preferences); - 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$ - } - - public void test028() { - runTest("test028", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test029() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.keep_simple_if_on_one_line = true; - preferences.keep_then_statement_on_same_line = true; - preferences.keep_guardian_clause_on_one_line = true; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.compact_else_if = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter,"test029", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test030() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.keep_simple_if_on_one_line = true; - preferences.keep_then_statement_on_same_line = true; - preferences.keep_guardian_clause_on_one_line = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test030", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test031() { - runTest("test031", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test032() { - runTest("test032", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test033() { - runTest("test033", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test034() { - runTest("test034", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test035() { - runTest("test035", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test036() { - runTest("test036", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test037() { - runTest("test037", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test038() { - runTest("test038", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test039() { - runTest("test039", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test040() { - runTest("test040", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test041() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test041", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test042() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.insert_space_before_opening_brace_in_block = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test042", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test043() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test043", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test044() { - runTest("test044", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test045() { - runTest("test045", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test046() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_after_assignment_operator = false; - preferences.insert_space_before_assignment_operator = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test046", "A.java", CodeFormatter.K_EXPRESSION);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test047() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_after_assignment_operator = true; - preferences.insert_space_before_assignment_operator = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test047", "A.java", CodeFormatter.K_STATEMENTS, 2);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test048() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_after_assignment_operator = true; - preferences.insert_space_before_assignment_operator = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test048", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test049() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_after_assignment_operator = true; - preferences.insert_space_before_assignment_operator = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test049", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test050() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_after_additive_operator = false; - preferences.insert_space_before_unary_operator = false; - preferences.insert_space_after_unary_operator = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test050", "A.java", CodeFormatter.K_EXPRESSION);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test051() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_after_assignment_operator = true; - preferences.insert_space_before_assignment_operator = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test051", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test052() { - runTest("test052", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test053() { - runTest("test053", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test054() { - runTest("test054", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test055() { - runTest("test055", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test056() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.keep_simple_if_on_one_line = true; - preferences.keep_then_statement_on_same_line = true; - preferences.keep_else_statement_on_same_line = true; - preferences.keep_guardian_clause_on_one_line = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test056", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test057() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - assertEquals(false, DefaultCodeFormatterConstants.getForceWrapping((String)options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER))); - assertEquals(DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.getWrappingStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER))); - assertEquals(DefaultCodeFormatterConstants.INDENT_DEFAULT, DefaultCodeFormatterConstants.getIndentStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER))); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.align_type_members_on_columns = true; - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test057", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test058() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - assertEquals(false, DefaultCodeFormatterConstants.getForceWrapping((String)options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER))); - assertEquals(DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.getWrappingStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER))); - assertEquals(DefaultCodeFormatterConstants.INDENT_DEFAULT, DefaultCodeFormatterConstants.getIndentStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER))); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.align_type_members_on_columns = true; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.number_of_empty_lines_to_preserve = 0; - preferences.blank_lines_between_import_groups = 0; - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test058", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test059() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.align_type_members_on_columns = false; - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test059", "Parser.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test060() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.align_type_members_on_columns = false; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.number_of_empty_lines_to_preserve = 0; - preferences.blank_lines_between_import_groups = 0; - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - //long time = System.currentTimeMillis(); - runTest(codeFormatter, "test060", "Parser.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test061() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.number_of_empty_lines_to_preserve = 0; - preferences.blank_lines_between_import_groups = 0; - preferences.align_type_members_on_columns = false; - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test061", "Parser.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test062() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_after_assignment_operator = true; - preferences.insert_space_before_assignment_operator = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test062", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test063() { - runTest("test063", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test064() { - runTest("test064", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // Line break inside an array initializer (line comment) - public void test065() { - runTest("test065", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test066() { - runTest("test066", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test067() { - runTest("test067", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 3181 - public void test068() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.number_of_empty_lines_to_preserve = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test068", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 3327 - public void test069() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.number_of_empty_lines_to_preserve = 0; - preferences.blank_lines_before_first_class_body_declaration = 1; - preferences.blank_lines_before_method = 1; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test069", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // 5691 - public void test070() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test070", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test071() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.indent_body_declarations_compare_to_type_header = false; - preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.align_type_members_on_columns = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test071", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 7224 - public void test072() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.number_of_empty_lines_to_preserve = 1; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test072", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 7439 - public void test073() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.number_of_empty_lines_to_preserve = 0; - preferences.keep_simple_if_on_one_line = true; - preferences.keep_then_statement_on_same_line = true; - preferences.keep_guardian_clause_on_one_line = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test073", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 12321 - public void test074() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.number_of_empty_lines_to_preserve = 0; - preferences.insert_new_line_before_catch_in_try_statement = true; - preferences.insert_new_line_before_else_in_if_statement = true; - preferences.insert_new_line_before_finally_in_try_statement = true; - preferences.insert_new_line_before_while_in_do_statement = true; - preferences.keep_simple_if_on_one_line = false; - preferences.keep_then_statement_on_same_line = false; - preferences.keep_else_statement_on_same_line = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test074", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 14659 - public void test075() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.page_width = 57; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test075", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 16231 - public void test076() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test076", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 16233 - public void test077() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test077", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 17349 - public void test078() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.brace_position_for_block = DefaultCodeFormatterConstants.NEXT_LINE; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test078", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 19811 - public void test079() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.number_of_empty_lines_to_preserve = 0; - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test079", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 19811 - public void test080() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.continuation_indentation = 2; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test080", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 19811 - public void test081() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test081", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 19999 - public void test082() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.number_of_empty_lines_to_preserve = 2; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test082", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 20721 - public void test083() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test083", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 21943 - public void test084() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.number_of_empty_lines_to_preserve = 0; - preferences.insert_space_before_opening_paren_in_if = false; - preferences.insert_space_before_opening_paren_in_for = false; - preferences.insert_space_before_opening_paren_in_while = false; - preferences.keep_simple_if_on_one_line = true; - preferences.keep_then_statement_on_same_line = true; - preferences.keep_guardian_clause_on_one_line = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test084", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 21943 - public void test085() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.number_of_empty_lines_to_preserve = 0; - preferences.insert_space_before_opening_paren_in_if = true; - preferences.insert_space_before_opening_paren_in_for = true; - preferences.insert_space_before_opening_paren_in_while = true; - preferences.keep_simple_if_on_one_line = true; - preferences.keep_then_statement_on_same_line = true; - preferences.keep_guardian_clause_on_one_line = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test085", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 22313 - public void test086() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_new_line_before_catch_in_try_statement = true; - preferences.insert_new_line_before_else_in_if_statement = true; - preferences.insert_new_line_before_finally_in_try_statement = true; - preferences.insert_new_line_before_while_in_do_statement = true; - preferences.brace_position_for_block = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.brace_position_for_method_declaration = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.insert_space_before_relational_operator = false; - preferences.insert_space_after_relational_operator = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test086", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 23144 - public void test087() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.keep_simple_if_on_one_line = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test087", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 23144 - public void test088() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.keep_simple_if_on_one_line = false; - preferences.keep_guardian_clause_on_one_line = false; - preferences.keep_then_statement_on_same_line = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test088", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 24200 - public void test089() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_after_opening_paren_in_parenthesized_expression = true; - preferences.insert_space_before_closing_paren_in_parenthesized_expression = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test089", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 24200 - public void test090() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_after_opening_bracket_in_array_reference = true; - preferences.insert_space_before_closing_bracket_in_array_reference = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test090", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 25559 - public void test091() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_after_assignment_operator = false; - preferences.insert_space_before_assignment_operator = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test091", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 25559 - public void test092() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_after_relational_operator = false; - preferences.insert_space_before_relational_operator = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test092", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 25559 - public void test093() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_after_closing_paren_in_cast = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test093", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 25559 - public void test094() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_after_assignment_operator = false; - preferences.insert_space_before_assignment_operator = false; - preferences.insert_space_after_comma_in_method_invocation_arguments = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test094", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 27196 - public void test095() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.brace_position_for_block = DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED; - preferences.indent_statements_compare_to_block = false; - preferences.indent_statements_compare_to_body = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test095", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 28098 - public void test096() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.join_lines_in_comments = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test096", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS + CodeFormatter.F_INCLUDE_COMMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 34897 - public void test097() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_after_opening_paren_in_method_invocation = true; - preferences.insert_space_before_closing_paren_in_method_invocation = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test097", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 35173 - public void test098() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.brace_position_for_anonymous_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.brace_position_for_method_declaration = DefaultCodeFormatterConstants.NEXT_LINE; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test098", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 35433 - public void test099() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_before_opening_paren_in_method_declaration = true; - preferences.insert_space_before_opening_paren_in_for = true; - preferences.insert_space_after_semicolon_in_for = false; - preferences.put_empty_statement_on_new_line = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test099", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test100() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_before_opening_brace_in_array_initializer = true; - preferences.insert_space_after_opening_brace_in_array_initializer = true; - preferences.insert_space_before_closing_brace_in_array_initializer = true; - preferences.number_of_empty_lines_to_preserve = 1; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test100", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 36832 - public void test101() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test101", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 37057 - public void test102() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.number_of_empty_lines_to_preserve = 1; - preferences.line_separator = "\n";//$NON-NLS-1$ - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test102", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 37106 - public void test103() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test103", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 37657 - public void test104() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_after_opening_paren_in_if = true; - preferences.insert_space_before_closing_paren_in_if = true; - preferences.brace_position_for_block = DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED; - preferences.insert_new_line_before_catch_in_try_statement = true; - preferences.insert_new_line_before_else_in_if_statement = true; - preferences.insert_new_line_before_finally_in_try_statement = true; - preferences.insert_new_line_before_while_in_do_statement = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test104", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 38151 - public void test105() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.brace_position_for_method_declaration = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test105", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 39603 - public void test106() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test106", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 39607 - public void test107() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.keep_then_statement_on_same_line = false; - preferences.keep_simple_if_on_one_line = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test107", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 40777 - public void test108() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test108", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test109() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.blank_lines_before_package = 2; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test109", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test110() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.blank_lines_before_package = 1; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test110", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test111() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.blank_lines_after_package = 1; - preferences.blank_lines_before_first_class_body_declaration = 1; - preferences.blank_lines_before_new_chunk = 1; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test111", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test112() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.blank_lines_after_package = 1; - preferences.blank_lines_before_first_class_body_declaration = 1; - preferences.blank_lines_before_new_chunk = 1; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test112", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test113() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test113", "A.java");//$NON-NLS-1$ //$NON-NLS-2 - } - - // bug 14659 - public void test114() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - assertEquals(false, DefaultCodeFormatterConstants.getForceWrapping((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION))); - assertEquals(DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.getWrappingStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION))); - assertEquals(DefaultCodeFormatterConstants.INDENT_ON_COLUMN, DefaultCodeFormatterConstants.getIndentStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION))); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.page_width = 57; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test114", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 14659 - public void test115() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.page_width = 57; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test115", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // bug 14659 - public void test116() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.page_width = 57; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test116", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // JDT/UI tests - public void test117() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test117", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // JDT/UI tests - public void test118() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test118", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // JDT/UI tests - public void test119() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test119", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // JDT/UI tests - public void test120() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test120", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // JDT/UI tests - public void test121() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test121", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // probing statements - public void test122() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test122", "A.java", CodeFormatter.K_UNKNOWN);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // probing compilation unit - public void test123() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test123", "A.java", CodeFormatter.K_UNKNOWN);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // probing class body declarations - public void test124() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.page_width = 57; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test124", "A.java", CodeFormatter.K_UNKNOWN);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // probing expression - public void test125() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_after_additive_operator = false; - preferences.insert_space_before_unary_operator = false; - preferences.insert_space_after_unary_operator = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test125", "A.java", CodeFormatter.K_UNKNOWN);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // probing unrecognized source - public void test126() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test126", "A.java", CodeFormatter.K_UNKNOWN, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // probing unrecognized source - public void test127() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test127", "A.java", CodeFormatter.K_UNKNOWN);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // probing unrecognized source - public void test128() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test128", "A.java", CodeFormatter.K_UNKNOWN, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test129() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test129", "A.java", CodeFormatter.K_STATEMENTS, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test130() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test130", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test131() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test131", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test132() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test132", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test133() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.blank_lines_between_import_groups = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test133", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test134() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test134", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test135() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test135", "A.java", CodeFormatter.K_STATEMENTS, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test136() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test136", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test137() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test137", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test138() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test138", "A.java", CodeFormatter.K_STATEMENTS, 2, true, 8, 37);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test139() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test139", "A.java", CodeFormatter.K_STATEMENTS, 0, true, 0, 5);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test140() { - setComplianceLevel(CompilerOptions.VERSION_14); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test140", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test141() { - setComplianceLevel(CompilerOptions.VERSION_14); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.indent_switchstatements_compare_to_cases = false; - preferences.indent_switchstatements_compare_to_switch = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test141", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test142() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test142", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, 1);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test143() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test143", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, 1);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test144() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test144", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test145() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test145", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test146() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test146", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test147() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_before_assignment_operator = false; - preferences.number_of_empty_lines_to_preserve = 1; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test147", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test148() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test148", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test149() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test149", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test150() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test150", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test151() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test151", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test152() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test152", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test153() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.align_type_members_on_columns = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test153", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test154() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test154", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test155() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getJavaConventionsSettings()); - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.tab_size = 4; - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test155", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - //https://bugs.eclipse.org/bugs/show_bug.cgi?id=44036 - public void test156() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getJavaConventionsSettings()); - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.tab_size = 4; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test156", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test157() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test157", "A.java", CodeFormatter.K_STATEMENTS, 0, true, 11, 7);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test158() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test158", "A.java", CodeFormatter.K_STATEMENTS, 0, true, 11, 8);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test159() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 1; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test159", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /* - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44481 - */ - public void test160() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.insert_new_line_before_catch_in_try_statement = false; - preferences.insert_new_line_before_else_in_if_statement = false; - preferences.insert_new_line_before_finally_in_try_statement = false; - preferences.insert_new_line_before_while_in_do_statement = false; - preferences.compact_else_if = true; - preferences.number_of_empty_lines_to_preserve = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test160", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /* - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44481 - */ - public void test161() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.insert_new_line_before_catch_in_try_statement = false; - preferences.insert_new_line_before_else_in_if_statement = false; - preferences.insert_new_line_before_finally_in_try_statement = false; - preferences.insert_new_line_before_while_in_do_statement = false; - preferences.compact_else_if = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test161", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /* - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44481 - */ - public void test162() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.insert_new_line_before_catch_in_try_statement = true; - preferences.insert_new_line_before_else_in_if_statement = true; - preferences.insert_new_line_before_finally_in_try_statement = true; - preferences.insert_new_line_before_while_in_do_statement = true; - preferences.compact_else_if = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test162", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /* - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44481 - */ - public void test163() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.insert_new_line_before_catch_in_try_statement = true; - preferences.insert_new_line_before_else_in_if_statement = true; - preferences.insert_new_line_before_finally_in_try_statement = true; - preferences.insert_new_line_before_while_in_do_statement = true; - preferences.compact_else_if = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test163", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44493 - */ - public void test164() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test164", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test165() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test165", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44546 - */ - public void test166() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test166", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44503 - */ - public void test167() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - 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.wrap_outer_expressions_when_nested = false; - 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 - */ - public void test169() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - 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.wrap_outer_expressions_when_nested = false; - 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 - */ - public void test170() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - 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.wrap_outer_expressions_when_nested = false; - 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 - */ - public void test171() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.brace_position_for_anonymous_type_declaration = DefaultCodeFormatterConstants.END_OF_LINE; - preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.END_OF_LINE; - preferences.brace_position_for_method_declaration = DefaultCodeFormatterConstants.END_OF_LINE; - preferences.brace_position_for_block = DefaultCodeFormatterConstants.END_OF_LINE; - preferences.brace_position_for_switch = DefaultCodeFormatterConstants.END_OF_LINE; - preferences.compact_else_if = false; - preferences.insert_new_line_before_catch_in_try_statement = true; - preferences.insert_new_line_before_else_in_if_statement = true; - preferences.insert_new_line_before_finally_in_try_statement = true; - preferences.insert_new_line_before_while_in_do_statement = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test171", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44576 - */ - public void test172() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.number_of_empty_lines_to_preserve = 0; - preferences.brace_position_for_anonymous_type_declaration = DefaultCodeFormatterConstants.END_OF_LINE; - preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.END_OF_LINE; - preferences.brace_position_for_method_declaration = DefaultCodeFormatterConstants.END_OF_LINE; - preferences.brace_position_for_block = DefaultCodeFormatterConstants.END_OF_LINE; - preferences.brace_position_for_switch = DefaultCodeFormatterConstants.END_OF_LINE; - preferences.compact_else_if = false; - preferences.insert_new_line_before_catch_in_try_statement = true; - preferences.insert_new_line_before_else_in_if_statement = true; - preferences.insert_new_line_before_finally_in_try_statement = true; - preferences.insert_new_line_before_while_in_do_statement = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test172", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44570 - */ - public void test173() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_code_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test173", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44570 - */ - public void test174() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_code_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test174", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44570 - */ - public void test175() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test175", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44570 - */ - public void test176() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test176", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44570 - */ - public void test177() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test177", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44570 - */ - public void test178() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test178", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44570 - */ - public void test179() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test179", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44570 - */ - public void test180() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test180", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44651 - */ - public void test181() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test181", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44651 - */ - public void test182() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.number_of_empty_lines_to_preserve = 1; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test182", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44653 - */ - public void test183() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.number_of_empty_lines_to_preserve = 1; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test183", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44653 - */ - public void test184() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test184", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44653 - */ - public void test185() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test185", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void _test186() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test186", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44839 - */ - public void test187() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.blank_lines_between_import_groups = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test187", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44839 - */ - public void test188() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test188", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44839 - */ - public void test189() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.align_selector_in_method_invocation_on_expression_first_line = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test189", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test190() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1"); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test190", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test191() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test191", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test192() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.number_of_empty_lines_to_preserve = 0; - preferences.align_type_members_on_columns = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test192", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test193() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test193", "A.java", CodeFormatter.K_STATEMENTS, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test194() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test194", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test195() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test195", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test196() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test196", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test197() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test197", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test198() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test198", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test199() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test199", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test201() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test201", "A.java", CodeFormatter.K_STATEMENTS, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test202() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test202", "A.java", CodeFormatter.K_STATEMENTS, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test203() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test203", "A.java", CodeFormatter.K_STATEMENTS, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test204() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test204", "A.java", CodeFormatter.K_STATEMENTS, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test205() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1");//$NON-NLS-1$ - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test205", "A.java", CodeFormatter.K_STATEMENTS, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test206() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test206", "A.java", CodeFormatter.K_STATEMENTS, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test207() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test207", "A.java", CodeFormatter.K_STATEMENTS, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test208() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test208", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test209() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1");//$NON-NLS-1$ - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test209", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test210() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1");//$NON-NLS-1$ - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test210", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test211() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1");//$NON-NLS-1$ - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test211", "A.java", CodeFormatter.K_COMPILATION_UNIT, 1);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test212() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test212", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test213() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test213", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test214() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test214", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test215() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test215", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test216() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test216", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test217() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test217", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test218() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test218", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, 1);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test219() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test219", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, 1);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test220() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test220", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, 1);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test221() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test221", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test222() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test222", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - public void test223() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test223", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test224() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test224", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test225() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test225", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test226() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test226", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test227() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test227", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test228() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test228", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test229() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test229", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test230() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test230", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test231() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test231", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test232() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test232", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test233() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test233", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, 1);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test234() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test234", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test235() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test235", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test236() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test236", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test237() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test237", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test238() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test238", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test239() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test239", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test240() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test240", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test242() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test242", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test244() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test244", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test245() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test245", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test246() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test246", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test247() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test247", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test248() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test248", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test249() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test249", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test250() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test250", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test251() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test251", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test252() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test252", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test253() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test253", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test254() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test254", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test255() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test255", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test256() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test256", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test257() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test257", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test258() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test258", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test259() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test259", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test260() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test260", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test261() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test261", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test262() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test262", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test263() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test263", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test264() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test264", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test265() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test265", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test266() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test266", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test267() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test267", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test268() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test268", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test269() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test269", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test270() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test270", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test271() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test271", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test272() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK_IN_CASE, DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test272", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test273() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK_IN_CASE, DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test273", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test274() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test274", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test275() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test275", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test276() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test276", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test277() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test277", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test278() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test278", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test279() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test279", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test280() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test280", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test281() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test281", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test282() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test282", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test283() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test283", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test284() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test284", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test285() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test285", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test286() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test286", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test287() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test287", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test288() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test288", "A.java", CodeFormatter.K_STATEMENTS, 1);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test289() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test289", "A.java", CodeFormatter.K_STATEMENTS, 1);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test290() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test290", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test291() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test291", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test292() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test292", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test293() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test293", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test294() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test294", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test295() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test295", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test296() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test296", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test297() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); - options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "100"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.number_of_empty_lines_to_preserve = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test297", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test298() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "80"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test298", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test299() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "80"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test299", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test300() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test300", "A.java", CodeFormatter.K_EXPRESSION, 2);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test301() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST, JavaCore.DO_NOT_INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test301", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test302() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.number_of_empty_lines_to_preserve = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test302", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test303() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.number_of_empty_lines_to_preserve = 0; - preferences.indent_switchstatements_compare_to_cases = true; - preferences.indent_switchstatements_compare_to_switch = true; - preferences.indent_breaks_compare_to_cases = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test303", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test304() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.indent_switchstatements_compare_to_cases = true; - preferences.indent_switchstatements_compare_to_switch = true; - preferences.indent_breaks_compare_to_cases = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test304", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test305() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.indent_switchstatements_compare_to_cases = false; - preferences.indent_switchstatements_compare_to_switch = true; - preferences.indent_breaks_compare_to_cases = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test305", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test306() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.indent_switchstatements_compare_to_cases = true; - preferences.indent_switchstatements_compare_to_switch = true; - preferences.indent_breaks_compare_to_cases = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test306", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test307() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.indent_switchstatements_compare_to_cases = true; - preferences.indent_switchstatements_compare_to_switch = true; - preferences.indent_breaks_compare_to_cases = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test307", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test308() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.indent_switchstatements_compare_to_cases = false; - preferences.indent_switchstatements_compare_to_switch = false; - preferences.indent_breaks_compare_to_cases = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test308", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test309() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.indent_switchstatements_compare_to_cases = false; - preferences.indent_switchstatements_compare_to_switch = false; - preferences.indent_breaks_compare_to_cases = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test309", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test310() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test310", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test311() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test311", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test312() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test312", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test313() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test313", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test314() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test314", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test315() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - String source = "public final void addDefinitelyAssignedVariables(Scope scope, int initStateIndex) {\n" + - "/*\n" + - " \n" + - "*/\n" + - "}"; - String expectedResult = "public final void addDefinitelyAssignedVariables(Scope scope,\r\n" + - " int initStateIndex) {\r\n" + - " /*\r\n" + - " \r\n" + - " */\r\n" + - "}"; - runTest(source, expectedResult, codeFormatter, CodeFormatter.K_CLASS_BODY_DECLARATIONS, 0, false, 0, -1); - } - - public void test316() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - String source = "public final void addDefinitelyAssignedVariables(Scope scope, int initStateIndex) {\r" + - "/*\r" + - " \r" + - "*/\r" + - "}"; - String expectedResult = "public final void addDefinitelyAssignedVariables(Scope scope,\r\n" + - " int initStateIndex) {\r\n" + - " /*\r\n" + - " \r\n" + - " */\r\n" + - "}"; - runTest(source, expectedResult, codeFormatter, CodeFormatter.K_CLASS_BODY_DECLARATIONS, 0, false, 0, -1); - } - - public void test317() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.line_separator = "\n"; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - String source = "public final void addDefinitelyAssignedVariables(Scope scope, int initStateIndex) {\r\n" + - "/*\r\n" + - " \r\n" + - "*/\r\n" + - "}"; - String expectedResult = "public final void addDefinitelyAssignedVariables(Scope scope,\n" + - " int initStateIndex) {\n" + - " /*\n" + - " \n" + - " */\n" + - "}"; - runTest(source, expectedResult, codeFormatter, CodeFormatter.K_CLASS_BODY_DECLARATIONS, 0, false, 0, -1); - } - - public void test318() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.line_separator = "\r"; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - String source = "public final void addDefinitelyAssignedVariables(Scope scope, int initStateIndex) {\r" + - "/*\r" + - " \r" + - "*/\r" + - "}"; - String expectedResult = "public final void addDefinitelyAssignedVariables(Scope scope,\r" + - " int initStateIndex) {\r" + - " /*\r" + - " \r" + - " */\r" + - "}"; - runTest(source, expectedResult, codeFormatter, CodeFormatter.K_CLASS_BODY_DECLARATIONS, 0, false, 0, -1); - } - - public void test319() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test319", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test320() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test320", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test321() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test321", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test322() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test322", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test323() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_code_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test323", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=45141 - */ - public void test324() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test324", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=45220 - */ - public void test325() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test325", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=45465 - */ - public void test326() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test326", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=45508 - */ - public void test327() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test327", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=22073 - */ - public void test328() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test328", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=29473 - */ - public void test329() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test329", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=27249 - */ - public void test330() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.keep_empty_array_initializer_on_one_line = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test330", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=23709 - */ - public void test331() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test331", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=23709 - */ - public void test332() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test332", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=45968 - */ - public void test333() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.number_of_empty_lines_to_preserve = 5; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test333", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=46058 - */ - public void test334() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.put_empty_statement_on_new_line = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test334", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=46033 - */ - public void test335() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test335", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=46023 - */ - public void test336() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.number_of_empty_lines_to_preserve = 0; - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test336", "A.java", CodeFormatter.K_STATEMENTS, 8);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=46150 - */ - public void test337() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.number_of_empty_lines_to_preserve = 0; - 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.wrap_outer_expressions_when_nested = false; - 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 - */ - public void test338() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test338", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=46686 - */ - public void test339() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test339", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=46686 - */ - public void test340() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test340", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=46689 - */ - public void test341() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_before_unary_operator = false; - preferences.insert_space_after_assignment_operator = false; - preferences.insert_space_after_additive_operator = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test341", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=46690 - */ - public void test342() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_after_comma_in_multiple_local_declarations = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test342", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=46690 - */ - public void test343() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_after_comma_in_multiple_field_declarations = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test343", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=46690 - */ - public void test344() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_after_comma_in_multiple_field_declarations = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test344", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=46690 - */ - public void test345() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_after_comma_in_multiple_local_declarations = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test345", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44493 - */ - public void test347() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - assertEquals(DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.getWrappingStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION))); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.blank_lines_before_method = 1; - preferences.blank_lines_before_first_class_body_declaration = 1; - preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test347", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44493 - */ - public void test348() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.blank_lines_before_method = 1; - preferences.blank_lines_before_first_class_body_declaration = 1; - preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test348", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44493 - */ - public void test349() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getJavaConventionsSettings()); - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.tab_size = 4; - preferences.blank_lines_before_first_class_body_declaration = 1; - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test349", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44653 - */ - public void test350() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test350", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44765 - */ - public void test351() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test351", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44653 - */ - public void test352() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getJavaConventionsSettings()); - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.tab_size = 4; - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test352", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44642 - */ - public void test353() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test353", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47799 - */ - public void test354() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, DefaultCodeFormatterConstants.FALSE); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test354", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47799 - */ - public void test355() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, DefaultCodeFormatterConstants.TRUE); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test355", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47800 - */ - public void test356() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_MULTIPLICATIVE_OPERATOR, DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test356", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47801 - */ - public void test357() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_PREFIX_OPERATOR, JavaCore.INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test357", "A.java", CodeFormatter.K_EXPRESSION);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47801 - */ - public void test358() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_PREFIX_OPERATOR, JavaCore.DO_NOT_INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test358", "A.java", CodeFormatter.K_EXPRESSION);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47811 - */ - public void test359() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test359", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47811 - */ - public void test360() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "2"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test360", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47811 - */ - public void test361() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test361", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47802 - */ - public void test362() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.page_width = 57; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test362", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47800 - */ - public void test363() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test363", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47986 - */ - public void test364() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_after_comma_in_for_inits = false; - preferences.insert_space_after_comma_in_for_increments = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test364", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47986 - */ - public void test365() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_after_comma_in_for_inits = false; - preferences.insert_space_after_comma_in_for_increments = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test365", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47986 - */ - public void test366() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_after_comma_in_for_inits = true; - preferences.insert_space_before_comma_in_for_inits = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test366", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47986 - */ - public void test367() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_after_comma_in_for_inits = true; - preferences.insert_space_before_comma_in_for_inits = true; - preferences.insert_space_after_comma_in_multiple_local_declarations = false; - preferences.insert_space_before_comma_in_multiple_local_declarations = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test367", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47918 - */ - public void test368() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1"); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_METHOD, "0"); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); - runTest(codeFormatter, "test368", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47918 - */ - public void test369() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "0"); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_METHOD, "1"); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_FIRST_CLASS_BODY_DECLARATION, "1"); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); - runTest(codeFormatter, "test369", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47918 - */ - public void test370() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1"); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_METHOD, "1"); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_FIRST_CLASS_BODY_DECLARATION, "1"); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); - runTest(codeFormatter, "test370", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47918 - */ - public void test371() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1"); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_METHOD, "0"); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); - runTest(codeFormatter, "test371", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47918 - */ - public void test372() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1"); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_METHOD, "0"); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); - runTest(codeFormatter, "test372", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47918 - */ - public void test373() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "0"); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_METHOD, "1"); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_FIRST_CLASS_BODY_DECLARATION, "1"); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); - runTest(codeFormatter, "test373", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44813 - */ - public void test374() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER, "1"); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); - runTest(codeFormatter, "test374", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44813 - */ - public void test375() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER, "1"); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); - runTest(codeFormatter, "test375", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44813 - */ - public void test376() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER, "1"); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); - runTest(codeFormatter, "test376", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44813 - */ - public void test377() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER, "1"); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); - runTest(codeFormatter, "test377", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44813 - */ - public void test378() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER, DefaultCodeFormatterConstants.END_OF_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER, "1"); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); - runTest(codeFormatter, "test378", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47997 - */ - public void test379() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER, DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED); - options.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER, "1"); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); - runTest(codeFormatter, "test379", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47997 - */ - public void test380() { - Hashtable options = new Hashtable(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_FIRST_CLASS_BODY_DECLARATION, "1"); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); - options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "100"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.number_of_empty_lines_to_preserve = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test380", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47997 - */ - public void test381() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "0"); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_METHOD, "1"); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_FIRST_CLASS_BODY_DECLARATION, "0"); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); - runTest(codeFormatter, "test381", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48131 - */ - public void test382() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); - runTest(codeFormatter, "test382", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48141 - */ - public void test383() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.tab_size = 4; - preferences.blank_lines_before_first_class_body_declaration = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test383", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48143 - */ - public void _test384() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION, - DefaultCodeFormatterConstants.createAlignmentValue(true, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.tab_size = 4; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test384", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48143 - */ - public void test385() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION, - DefaultCodeFormatterConstants.createAlignmentValue(true, DefaultCodeFormatterConstants.WRAP_NEXT_SHIFTED, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - assertEquals(DefaultCodeFormatterConstants.WRAP_NEXT_SHIFTED, DefaultCodeFormatterConstants.getWrappingStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION))); - assertTrue(DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE != DefaultCodeFormatterConstants.getWrappingStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION))); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.blank_lines_before_first_class_body_declaration = 0; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.tab_size = 4; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test385", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48143 - */ - public void test386() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION, - DefaultCodeFormatterConstants.createAlignmentValue(true, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.blank_lines_before_first_class_body_declaration = 0; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.tab_size = 4; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test386", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48143 - */ - public void _test387() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); -// options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "40"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.page_width = 40; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.tab_size = 4; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test387", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48167 - */ - public void test388() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.tab_size = 4; - preferences.brace_position_for_array_initializer = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.page_width = 40; - preferences.insert_new_line_after_opening_brace_in_array_initializer = true; - preferences.insert_new_line_before_closing_brace_in_array_initializer = true; - preferences.blank_lines_before_first_class_body_declaration = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test388", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48167 - */ - public void test389() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, - DefaultCodeFormatterConstants.createAlignmentValue(true, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.continuation_indentation_for_array_initializer = 1; - preferences.brace_position_for_array_initializer = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.page_width = 40; - preferences.insert_new_line_after_opening_brace_in_array_initializer = true; - preferences.insert_new_line_before_closing_brace_in_array_initializer = true; - preferences.blank_lines_before_first_class_body_declaration = 0; - preferences.tab_size = 4; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test389", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48167 - */ - public void test390() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT_FIRST_BREAK, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.continuation_indentation_for_array_initializer = 1; - preferences.brace_position_for_array_initializer = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.page_width = 40; - preferences.insert_new_line_after_opening_brace_in_array_initializer = true; - preferences.insert_new_line_before_closing_brace_in_array_initializer = true; - preferences.blank_lines_before_first_class_body_declaration = 0; - preferences.tab_size = 4; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test390", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48167 - */ - public void test391() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_BY_ONE)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.blank_lines_before_first_class_body_declaration = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.continuation_indentation_for_array_initializer = 3; - preferences.brace_position_for_array_initializer = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.page_width = 40; - preferences.insert_new_line_after_opening_brace_in_array_initializer = true; - preferences.insert_new_line_before_closing_brace_in_array_initializer = true; - preferences.tab_size = 4; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test391", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48167 - */ - public void test392() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_BY_ONE)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.blank_lines_before_first_class_body_declaration = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.continuation_indentation_for_array_initializer = 3; - preferences.brace_position_for_array_initializer = DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED; - preferences.page_width = 40; - preferences.insert_new_line_after_opening_brace_in_array_initializer = true; - preferences.insert_new_line_before_closing_brace_in_array_initializer = true; - preferences.tab_size = 4; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test392", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48167 - */ - public void test393() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_size = 4; - preferences.blank_lines_before_first_class_body_declaration = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.continuation_indentation_for_array_initializer = 1; - preferences.brace_position_for_array_initializer = DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED; - preferences.page_width = 40; - preferences.insert_new_line_after_opening_brace_in_array_initializer = true; - preferences.insert_new_line_before_closing_brace_in_array_initializer = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test393", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48404 - */ - public void test394() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.number_of_empty_lines_to_preserve = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test394", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49318 - */ - public void test395() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.insert_space_before_opening_paren_in_method_declaration = true; - preferences.number_of_empty_lines_to_preserve = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test395", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49243 - */ - public void test396() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.insert_space_before_semicolon_in_for = true; - preferences.number_of_empty_lines_to_preserve = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test396", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49187 - */ - public void test397() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.blank_lines_before_package = 2; - preferences.blank_lines_after_package = 0; - preferences.number_of_empty_lines_to_preserve = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test397", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49187 - */ - public void test398() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.blank_lines_before_package = 0; - preferences.blank_lines_after_package = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test398", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49187 - */ - public void test399() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.blank_lines_before_package = 1; - preferences.blank_lines_after_package = 1; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test399", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49187 - */ - public void test400() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_PACKAGE, "2"); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AFTER_PACKAGE, "2"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test400", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49361 - */ - public void test401() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test401", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49361 - */ - public void test402() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test402", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49298 - */ - public void test403() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test403", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49298 - */ - public void test404() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION, JavaCore.DO_NOT_INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test404", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49187 - */ - public void test405() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_PACKAGE, "10"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.tab_size = 4; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test405", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49298 - */ - public void test406() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION, JavaCore.INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test406", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49481 - */ - public void test407() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_size = 4; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.blank_lines_before_first_class_body_declaration = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test407", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49481 - */ - public void test408() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_size = 4; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.blank_lines_before_first_class_body_declaration = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test408", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49378 - */ - public void test409() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK_IN_CASE, DefaultCodeFormatterConstants.NEXT_LINE); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.indent_switchstatements_compare_to_cases = false; - preferences.indent_switchstatements_compare_to_switch = true; - preferences.brace_position_for_block = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.brace_position_for_switch = DefaultCodeFormatterConstants.NEXT_LINE; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test409", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49577 - */ - public void test410() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.blank_lines_between_type_declarations = 1; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test410", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49577 - */ - public void test411() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.blank_lines_between_type_declarations = 2; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test411", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49551 - */ - public void test412() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test412", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49551 - */ - public void test413() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.blank_lines_between_type_declarations = 1; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test413", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49551 - */ - public void test414() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test414", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49551 - */ - public void test415() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.blank_lines_between_type_declarations = 1; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test415", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49551 - */ - public void test416() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.blank_lines_between_type_declarations = 1; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test416", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49571 - */ - public void test417() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_before_opening_paren_in_constructor_declaration = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test417", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49571 - */ - public void test418() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_before_opening_paren_in_constructor_declaration = true; - preferences.insert_space_before_opening_paren_in_method_declaration = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test418", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49298 - */ - public void test421() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION, JavaCore.DO_NOT_INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test421", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49298 - */ - public void test422() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION, JavaCore.DO_NOT_INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.blank_lines_before_first_class_body_declaration = 1; - preferences.tab_size = 4; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test422", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49351 - */ - public void test423() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test423", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49351 - */ - public void test424() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test424", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49351 - */ - public void test425() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test425", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49351 - */ - public void test426() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.number_of_empty_lines_to_preserve = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test426", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49351 - */ - public void test427() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.number_of_empty_lines_to_preserve = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test427", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49351 - */ - public void test428() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.number_of_empty_lines_to_preserve = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test428", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49351 - */ - public void test429() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.number_of_empty_lines_to_preserve = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test429", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49351 - */ - public void test430() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.number_of_empty_lines_to_preserve = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test430", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49351 - */ - public void test431() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR, JavaCore.INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.number_of_empty_lines_to_preserve = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test431", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49370 - */ - public void test432() { - String resourcePath = getResource("test432", "formatter.xml"); - Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "AIS"); - assertNotNull("No preferences", options); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test432", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49370 - */ - public void test433() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test433", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49660 - */ - public void test434() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, - DefaultCodeFormatterConstants.createAlignmentValue(true, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - assertEquals(true, DefaultCodeFormatterConstants.getForceWrapping((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION))); - assertEquals(DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.getWrappingStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION))); - assertEquals(DefaultCodeFormatterConstants.INDENT_ON_COLUMN, DefaultCodeFormatterConstants.getIndentStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION))); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.indentation_size = 3; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.insert_space_after_opening_paren_in_method_invocation = true; - preferences.insert_space_before_closing_paren_in_method_invocation = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test434", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49772 - */ - public void test435() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.brace_position_for_method_declaration = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.brace_position_for_block = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.blank_lines_before_first_class_body_declaration = 1; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.tab_size = 4; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test435", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49772 - */ - public void test436() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.brace_position_for_method_declaration = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.brace_position_for_constructor_declaration = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.brace_position_for_block = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.blank_lines_before_first_class_body_declaration = 1; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.tab_size = 4; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test436", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49660 - */ - public void test437() { - String resourcePath = getResource("test437", "formatter.xml"); - Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "Felix"); - assertNotNull("No preferences", options); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test437", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49660 - */ - public void test438() { - String resourcePath = getResource("test438", "formatter.xml"); - Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "Felix"); - assertNotNull("No preferences", options); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test438", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49660 - */ - public void test439() { - String resourcePath = getResource("test439", "formatter.xml"); - Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "Felix"); - assertNotNull("No preferences", options); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test439", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49763 - */ - public void test440() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, DefaultCodeFormatterConstants.FALSE); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test440", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49763 - */ - public void test441() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, DefaultCodeFormatterConstants.FALSE); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test441", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49763 - */ - public void test442() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, DefaultCodeFormatterConstants.FALSE); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test442", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49763 - */ - public void test443() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, DefaultCodeFormatterConstants.FALSE); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test443", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49763 - */ - public void test444() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, DefaultCodeFormatterConstants.FALSE); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test444", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49763 - */ - public void test445() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, DefaultCodeFormatterConstants.FALSE); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test445", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49327 - */ - public void test446() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.number_of_empty_lines_to_preserve = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test446", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49187 - */ - public void test447() { - String resourcePath = getResource("test447", "test447.zip"); - Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "settings.xml", "Toms"); - assertNotNull("No preferences", options); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - String input = getZipEntryContents(resourcePath, getIn("Format.java")); - assertNotNull("No input", input); - String output = getZipEntryContents(resourcePath, getOut("Format.java")); - assertNotNull("No output", output); - int start = input.indexOf("private"); - int end = input.indexOf(";"); - runTest(input, output, codeFormatter, CodeFormatter.K_COMPILATION_UNIT, 0, false, start, end - start + 1, "\r\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49953 - */ - public void test448() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.number_of_empty_lines_to_preserve = 0; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_before_opening_bracket_in_array_allocation_expression = true; - preferences.insert_space_after_opening_bracket_in_array_allocation_expression = true; - preferences.insert_space_before_closing_bracket_in_array_allocation_expression = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test448", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49953 - */ - public void test449() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.number_of_empty_lines_to_preserve = 0; - preferences.insert_space_before_opening_bracket_in_array_allocation_expression = false; - preferences.insert_space_after_opening_bracket_in_array_allocation_expression = true; - preferences.insert_space_before_closing_bracket_in_array_allocation_expression = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test449", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=50225 - */ - public void test450() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test450", "A.java", CodeFormatter.K_UNKNOWN, 0, false, 0, 0);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49187 - */ - public void test451() { - String resourcePath = getResource("test451", "test451.zip"); - Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "settings.xml", "Toms"); - assertNotNull("No preferences", options); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - String input = getZipEntryContents(resourcePath, getIn("Format.java")); - assertNotNull("No input", input); - String output = getZipEntryContents(resourcePath, getOut("Format.java")); - assertNotNull("No output", output); - int start = input.indexOf("private"); - int end = input.indexOf(";"); - runTest(input, output, codeFormatter, CodeFormatter.K_COMPILATION_UNIT, 0, false, start, end - start + 1, "\r\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49187 - */ - public void test452() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_PACKAGE, "2"); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AFTER_PACKAGE, "2"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test452", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=50719 - */ - public void test453() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.blank_lines_before_first_class_body_declaration = 1; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.tab_size = 4; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test453", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=50736 - */ - public void test454() { - String resourcePath = getResource("test454", "test454.zip"); - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1");//$NON-NLS-1$ - assertNotNull("No preferences", options); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - String input = getZipEntryContents(resourcePath, getIn("A.java")); - assertNotNull("No input", input); - String output = getZipEntryContents(resourcePath, getOut("A.java")); - assertNotNull("No output", output); - int start = input.indexOf("launch.setAttribute"); - int end = input.indexOf(";", start + 1); - runTest(input, output, codeFormatter, CodeFormatter.K_COMPILATION_UNIT, 0, false, start, end - start + 1, "\r\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=50736 - */ - public void test455() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1");//$NON-NLS-1$ - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - 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_WRAP_OUTER_EXPRESSIONS_WHEN_NESTED, DefaultCodeFormatterConstants.FALSE); - 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 - */ - public void test456() { - String resourcePath = getResource("test456", "test456.zip"); - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - assertNotNull("No preferences", options); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.number_of_empty_lines_to_preserve = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - String input = getZipEntryContents(resourcePath, getIn("A.java")); - assertNotNull("No input", input); - String output = getZipEntryContents(resourcePath, getOut("A.java")); - assertNotNull("No output", output); - int start = input.indexOf("launch.setAttribute"); - int end = input.indexOf(";", start + 1); - runTest(input, output, codeFormatter, CodeFormatter.K_COMPILATION_UNIT, 0, false, start, end - start + 1, "\r\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=50989 - */ - public void test457() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test457", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * Check null options - */ - public void test458() { - CodeFormatter codeFormatter = ToolFactory.createCodeFormatter(null); - runTest(codeFormatter, "test458", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51158 - */ - public void test459() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, - DefaultCodeFormatterConstants.createAlignmentValue( - true, - DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, - DefaultCodeFormatterConstants.INDENT_BY_ONE - )); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_STRING_CONCATENATION, - DefaultCodeFormatterConstants.createAlignmentValue( - false, - DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, - DefaultCodeFormatterConstants.INDENT_BY_ONE - )); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test459", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51158 - */ - public void test460() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ADDITIVE_OPERATOR, - DefaultCodeFormatterConstants.createAlignmentValue( - false, - DefaultCodeFormatterConstants.WRAP_COMPACT, - DefaultCodeFormatterConstants.INDENT_BY_ONE - )); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test460", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51190 - */ - public void test461() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test461", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51158 - */ - public void test462() { - String resourcePath = getResource("test462", "formatter.xml"); - Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "neils"); - assertNotNull("No preferences", options); - - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, - DefaultCodeFormatterConstants.createAlignmentValue( - true, - DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, - DefaultCodeFormatterConstants.INDENT_DEFAULT)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test462", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=50276 - */ - public void test463() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION, - DefaultCodeFormatterConstants.createAlignmentValue( - false, - DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, - DefaultCodeFormatterConstants.INDENT_DEFAULT)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.number_of_empty_lines_to_preserve = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test463", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51128 - */ - public void test464() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED); - options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK, DefaultCodeFormatterConstants.FALSE); - options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY, DefaultCodeFormatterConstants.TRUE); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); - - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test464", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44642 - * @deprecated - */ - public void test465() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION, - DefaultCodeFormatterConstants.createAlignmentValue( - false, - DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, - DefaultCodeFormatterConstants.INDENT_BY_ONE)); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, - DefaultCodeFormatterConstants.createAlignmentValue( - false, - DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, - DefaultCodeFormatterConstants.INDENT_BY_ONE)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test465", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44642 - * @deprecated - */ - public void test466() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION, - DefaultCodeFormatterConstants.createAlignmentValue( - false, - DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, - DefaultCodeFormatterConstants.INDENT_BY_ONE)); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, - DefaultCodeFormatterConstants.createAlignmentValue( - true, - DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, - DefaultCodeFormatterConstants.INDENT_BY_ONE)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test466", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44642 - * @deprecated - */ - public void test467() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION, - DefaultCodeFormatterConstants.createAlignmentValue( - false, - DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, - DefaultCodeFormatterConstants.INDENT_BY_ONE)); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, - DefaultCodeFormatterConstants.createAlignmentValue( - false, - DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, - DefaultCodeFormatterConstants.INDENT_BY_ONE)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test467", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51128 - */ - public void test468() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1");//$NON-NLS-1$ - - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test468", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51201 - */ - public void test469() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACKETS_IN_ARRAY_ALLOCATION_EXPRESSION, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); - - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test469", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51035 - */ - public void test470() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.keep_simple_if_on_one_line = true; - preferences.keep_guardian_clause_on_one_line = true; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.tab_size = 4; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test470", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51659 - */ - public void test471() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test471", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51659 - */ - public void test472() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test472", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51659 - */ - public void test473() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test473", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51659 - */ - public void test474() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test474", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51659 - */ - public void test475() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test475", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51768 - */ - public void test476() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_TYPE_HEADER, DefaultCodeFormatterConstants.FALSE); - options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK, DefaultCodeFormatterConstants.FALSE); - options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY, DefaultCodeFormatterConstants.FALSE); - options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1"); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AFTER_IMPORTS, "1"); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_IF, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_MULTIPLICATIVE_OPERATOR, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_MULTIPLICATIVE_OPERATOR, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_RELATIONAL_OPERATOR, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_RELATIONAL_OPERATOR, JavaCore.INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test476", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51603 - */ - public void test477() { - String option = - DefaultCodeFormatterConstants.createAlignmentValue( - true, - DefaultCodeFormatterConstants.WRAP_NO_SPLIT, - DefaultCodeFormatterConstants.INDENT_BY_ONE); - assertTrue("Wrong force setting", DefaultCodeFormatterConstants.getForceWrapping(option)); - assertEquals("Wrong wrapping style", DefaultCodeFormatterConstants.WRAP_NO_SPLIT, DefaultCodeFormatterConstants.getWrappingStyle(option)); - assertEquals("Wrong indent style", DefaultCodeFormatterConstants.INDENT_BY_ONE, DefaultCodeFormatterConstants.getIndentStyle(option)); - - option = DefaultCodeFormatterConstants.setForceWrapping(option, false); - assertFalse("Wrong force setting", DefaultCodeFormatterConstants.getForceWrapping(option)); - assertEquals("Wrong wrapping style", DefaultCodeFormatterConstants.WRAP_NO_SPLIT, DefaultCodeFormatterConstants.getWrappingStyle(option)); - assertEquals("Wrong indent style", DefaultCodeFormatterConstants.INDENT_BY_ONE, DefaultCodeFormatterConstants.getIndentStyle(option)); - - option = DefaultCodeFormatterConstants.setIndentStyle(option, DefaultCodeFormatterConstants.INDENT_ON_COLUMN); - assertFalse("Wrong force setting", DefaultCodeFormatterConstants.getForceWrapping(option)); - assertEquals("Wrong wrapping style", DefaultCodeFormatterConstants.WRAP_NO_SPLIT, DefaultCodeFormatterConstants.getWrappingStyle(option)); - assertEquals("Wrong indent style", DefaultCodeFormatterConstants.INDENT_ON_COLUMN, DefaultCodeFormatterConstants.getIndentStyle(option)); - - - option = DefaultCodeFormatterConstants.setIndentStyle(option, DefaultCodeFormatterConstants.INDENT_DEFAULT); - assertFalse("Wrong force setting", DefaultCodeFormatterConstants.getForceWrapping(option)); - assertEquals("Wrong wrapping style", DefaultCodeFormatterConstants.WRAP_NO_SPLIT, DefaultCodeFormatterConstants.getWrappingStyle(option)); - assertEquals("Wrong indent style", DefaultCodeFormatterConstants.INDENT_DEFAULT, DefaultCodeFormatterConstants.getIndentStyle(option)); - - - option = DefaultCodeFormatterConstants.setForceWrapping(option, true); - assertTrue("Wrong force setting", DefaultCodeFormatterConstants.getForceWrapping(option)); - assertEquals("Wrong wrapping style", DefaultCodeFormatterConstants.WRAP_NO_SPLIT, DefaultCodeFormatterConstants.getWrappingStyle(option)); - assertEquals("Wrong indent style", DefaultCodeFormatterConstants.INDENT_DEFAULT, DefaultCodeFormatterConstants.getIndentStyle(option)); - - - option = DefaultCodeFormatterConstants.setWrappingStyle(option, DefaultCodeFormatterConstants.WRAP_COMPACT); - assertTrue("Wrong force setting", DefaultCodeFormatterConstants.getForceWrapping(option)); - assertEquals("Wrong wrapping style", DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.getWrappingStyle(option)); - assertEquals("Wrong indent style", DefaultCodeFormatterConstants.INDENT_DEFAULT, DefaultCodeFormatterConstants.getIndentStyle(option)); - - - option = DefaultCodeFormatterConstants.setWrappingStyle(option, DefaultCodeFormatterConstants.WRAP_COMPACT_FIRST_BREAK); - assertTrue("Wrong force setting", DefaultCodeFormatterConstants.getForceWrapping(option)); - assertEquals("Wrong wrapping style", DefaultCodeFormatterConstants.WRAP_COMPACT_FIRST_BREAK, DefaultCodeFormatterConstants.getWrappingStyle(option)); - assertEquals("Wrong indent style", DefaultCodeFormatterConstants.INDENT_DEFAULT, DefaultCodeFormatterConstants.getIndentStyle(option)); - - option = DefaultCodeFormatterConstants.setWrappingStyle(option, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE); - assertTrue("Wrong force setting", DefaultCodeFormatterConstants.getForceWrapping(option)); - assertEquals("Wrong wrapping style", DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.getWrappingStyle(option)); - assertEquals("Wrong indent style", DefaultCodeFormatterConstants.INDENT_DEFAULT, DefaultCodeFormatterConstants.getIndentStyle(option)); - - option = DefaultCodeFormatterConstants.setWrappingStyle(option, DefaultCodeFormatterConstants.WRAP_NEXT_SHIFTED); - assertTrue("Wrong force setting", DefaultCodeFormatterConstants.getForceWrapping(option)); - assertEquals("Wrong wrapping style", DefaultCodeFormatterConstants.WRAP_NEXT_SHIFTED, DefaultCodeFormatterConstants.getWrappingStyle(option)); - assertEquals("Wrong indent style", DefaultCodeFormatterConstants.INDENT_DEFAULT, DefaultCodeFormatterConstants.getIndentStyle(option)); - - option = DefaultCodeFormatterConstants.setWrappingStyle(option, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE); - assertTrue("Wrong force setting", DefaultCodeFormatterConstants.getForceWrapping(option)); - assertEquals("Wrong wrapping style", DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.getWrappingStyle(option)); - assertEquals("Wrong indent style", DefaultCodeFormatterConstants.INDENT_DEFAULT, DefaultCodeFormatterConstants.getIndentStyle(option)); - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=52246 - */ - public void test478() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_4); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, options); - runTest(codeFormatter, "test478", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=52479 - */ - public void test479() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test479", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=52479 - */ - public void test480() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.number_of_empty_lines_to_preserve = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test480", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=52283 - */ - public void test481() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test481", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=52283 - */ - public void test482() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK, JavaCore.DO_NOT_INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test482", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=52851 - */ - public void test483() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK, JavaCore.DO_NOT_INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test483", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=50989 - */ - public void test484() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1");//$NON-NLS-1$ - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test484", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=50989 - */ - public void test485() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1");//$NON-NLS-1$ - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test485", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=50989 - */ - public void test486() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE);//$NON-NLS-1$ - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE);//$NON-NLS-1$ - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE);//$NON-NLS-1$ - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE);//$NON-NLS-1$ - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE);//$NON-NLS-1$ - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE);//$NON-NLS-1$ - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test486", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test487() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test487", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test488() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CASE, JavaCore.DO_NOT_INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test488", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test489() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, - DefaultCodeFormatterConstants.createAlignmentValue(true, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test489", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=52747 - */ - public void test490() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER, DefaultCodeFormatterConstants.NEXT_LINE); - options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, - DefaultCodeFormatterConstants.createAlignmentValue(true, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test490", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=59451 - */ - public void _test491() { - String resourcePath = getResource("test491", "formatter.xml"); - Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "DOI"); - assertNotNull("No preferences", options); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test491", "BundleChain.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=59575 - */ - public void test492() { - String resourcePath = getResource("test492", "core_formatting.xml"); - Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "core"); - assertNotNull("No preferences", options); - options.put(JavaCore.COMPILER_PB_NON_NLS_STRING_LITERAL, JavaCore.ERROR); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, options); - runTest(codeFormatter, "test492", "Main.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=59716 - */ - public void test493() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AFTER_PACKAGE, "1"); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_PACKAGE, "1"); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AFTER_IMPORTS, "1"); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_IMPORTS, "1"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test493", "MyClass.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=60035 - */ - public void test494() { - String resourcePath = getResource("test494", "format.xml"); - Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "AGPS default"); - assertNotNull("No preferences", options); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, options); - runTest(codeFormatter, "test494", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=58565 - */ - public void test495() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.blank_lines_before_first_class_body_declaration = 1; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.tab_size = 4; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test495", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=58565 - */ - public void test496() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_size = 4; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.keep_simple_if_on_one_line = true; - preferences.keep_guardian_clause_on_one_line = true; - preferences.blank_lines_before_first_class_body_declaration = 1; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test496", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test497() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.blank_lines_before_first_class_body_declaration = 1; - preferences.tab_size = 4; - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test497", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test498() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.keep_simple_if_on_one_line = true; - preferences.keep_guardian_clause_on_one_line = true; - preferences.tab_size = 4; - preferences.align_selector_in_method_invocation_on_expression_first_line = false; - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test498", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test499() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.blank_lines_before_first_class_body_declaration = 1; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.tab_size = 4; - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test499", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test500() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test500", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=68506 - */ - public void test501() { - String resourcePath = getResource("test501", "formatter.xml"); - Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "GMTI"); - assertNotNull("No preferences", options); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test501", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=69806 - */ - public void test502() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_size = 4; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test502", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * Formatting foreach - */ - public void test503() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_size = 4; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test503", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * Formatting parameterized type - */ - public void test504() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test504", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * Formatting parameterized type - */ - public void test505() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_size = 4; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test505", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * Formatting parameterized type - */ - public void test506() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_size = 4; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - setPageWidth80(preferences); - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test506", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * Formatting enum declaration - */ - public void test507() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_size = 4; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test507", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * Formatting annotation type declaration - */ - public void test508() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test508", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=68506 - */ - public void test509() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.keep_simple_if_on_one_line = true; - preferences.keep_then_statement_on_same_line = true; - preferences.keep_guardian_clause_on_one_line = true; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.compact_else_if = true; - preferences.insert_new_line_at_end_of_file_if_missing = true; - preferences.number_of_empty_lines_to_preserve = 0; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter,"test509", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=68506 - */ - public void test510() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.keep_simple_if_on_one_line = true; - preferences.keep_then_statement_on_same_line = true; - preferences.keep_guardian_clause_on_one_line = true; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.compact_else_if = true; - preferences.insert_new_line_at_end_of_file_if_missing = false; - preferences.number_of_empty_lines_to_preserve = 1; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter,"test510", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=68506 - */ - public void test511() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.keep_simple_if_on_one_line = true; - preferences.keep_then_statement_on_same_line = true; - preferences.keep_guardian_clause_on_one_line = true; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.compact_else_if = true; - preferences.insert_new_line_at_end_of_file_if_missing = false; - preferences.number_of_empty_lines_to_preserve = 1; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter,"test511", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=68506 - */ - public void test512() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); - preferences.keep_simple_if_on_one_line = true; - preferences.keep_then_statement_on_same_line = true; - preferences.keep_guardian_clause_on_one_line = true; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.compact_else_if = true; - preferences.insert_new_line_at_end_of_file_if_missing = true; - preferences.number_of_empty_lines_to_preserve = 1; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter,"test512", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=73371 - */ - public void test513() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test513", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=75488 - */ - public void test514() { - String resourcePath = getResource("test514", "formatter.xml"); - Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "core"); - assertNotNull("No preferences", options); - options.put(JavaCore.COMPILER_PB_NON_NLS_STRING_LITERAL, JavaCore.ERROR); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, options); - runTest(codeFormatter, "test514", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=75720 - */ - public void test515() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_size = 4; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test515", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=75720 - */ - public void test516() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ELLIPSIS, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ELLIPSIS, JavaCore.DO_NOT_INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test516", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=75720 - */ - public void test517() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ELLIPSIS, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ELLIPSIS, JavaCore.INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test517", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=75720 - */ - public void test518() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ELLIPSIS, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ELLIPSIS, JavaCore.INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test518", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=75720 - */ - public void test519() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ELLIPSIS, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ELLIPSIS, JavaCore.DO_NOT_INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test519", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * Formatting enum declaration - */ - public void test520() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test520", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=76642 - */ - public void test521() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test521", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=76642 - */ - public void test522() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test522", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=76766 - */ - public void test523() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - preferences.keep_enum_constant_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_enum_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test523", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=76766 - */ - public void test524() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - preferences.keep_enum_constant_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_enum_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test524", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=76766 - */ - public void test525() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - preferences.keep_enum_constant_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - preferences.keep_enum_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test525", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=76766 - */ - public void test526() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - preferences.keep_enum_constant_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - preferences.keep_enum_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test526", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=77249 - */ - public void test527() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.tab_size = 4; - setPageWidth80(preferences); - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test527", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - public void test527b() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.tab_size = 4; - preferences.alignment_for_arguments_in_annotation = Alignment.M_COMPACT_SPLIT; - setPageWidth80(preferences); - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test527b", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=79779 - */ - public void test528() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test528", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=79779 - */ - public void test529() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test529", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=79795 - */ - public void test530() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test530", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=79795 - */ - public void test531() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test531", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=79795 - */ - public void test532() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test532", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=79795 - */ - public void test533() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test533", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=78698 - */ - public void test534() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test534", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=78698 - */ - public void test535() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test535", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=78698 - */ - public void test536() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_after_question_in_wilcard = true; - preferences.insert_space_before_question_in_wilcard = true; - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test536", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=78698 - */ - public void test537() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.insert_space_after_question_in_wilcard = true; - preferences.insert_space_before_question_in_wilcard = true; - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test537", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=83078 - */ - public void test538() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getJavaConventionsSettings()); - preferences.tab_size = 4; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter,"test538", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=83515 - */ - public void test539() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test539", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=83515 - */ - public void test540() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test540", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=83684 - */ - public void test541() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.tab_size = 4; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test541", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - public void test542() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getJavaConventionsSettings()); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.tab_size = 4; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test542", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test543() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getJavaConventionsSettings()); - preferences.tab_size = 4; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test543", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=86410 - */ - public void test544() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_size = 4; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.insert_space_after_closing_angle_bracket_in_type_parameters = true; - preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test544", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=86878 - */ - public void test545() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_size = 4; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test545", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=86908 - */ - public void test546() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_size = 4; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test546", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * Add support for comment formatting - */ - public void test547() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.tab_size = 4; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test547", "A.java", CodeFormatter.K_MULTI_LINE_COMMENT, false);//$NON-NLS-1$ //$NON-NLS-2$ - - runTest(codeFormatter, "test547", "A.java", CodeFormatter.K_UNKNOWN, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * Add support for comment formatting - */ - public void test548() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.tab_size = 4; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test548", "A.java", CodeFormatter.K_JAVA_DOC, false);//$NON-NLS-1$ //$NON-NLS-2$ - - runTest(codeFormatter, "test548", "A.java", CodeFormatter.K_UNKNOWN, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=73104 - public void test549() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.MIXED; - preferences.indentation_size = 4; - preferences.tab_size = 8; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test549", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=73104 - public void test550() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.MIXED; - preferences.indentation_size = 4; - preferences.tab_size = 8; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test550", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=73104 - public void test551() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - assertEquals(false, DefaultCodeFormatterConstants.getForceWrapping((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION))); - assertEquals(DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.getWrappingStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION))); - assertEquals(DefaultCodeFormatterConstants.INDENT_ON_COLUMN, DefaultCodeFormatterConstants.getIndentStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION))); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.MIXED; - preferences.indentation_size = 4; - preferences.tab_size = 8; - preferences.page_width = 57; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test551", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=73104 - public void test552() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - assertEquals(false, DefaultCodeFormatterConstants.getForceWrapping((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION))); - assertEquals(DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.getWrappingStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION))); - assertEquals(DefaultCodeFormatterConstants.INDENT_ON_COLUMN, DefaultCodeFormatterConstants.getIndentStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION))); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.MIXED; - preferences.indentation_size = 4; - preferences.tab_size = 8; - preferences.page_width = 57; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test552", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * Add support for comment formatting - */ - public void test553() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.comment_format_line_comment_starting_on_first_column = true; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.tab_size = 4; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test553", "A.java", CodeFormatter.K_SINGLE_LINE_COMMENT, false);//$NON-NLS-1$ //$NON-NLS-2$ - - runTest(codeFormatter, "test553", "A.java", CodeFormatter.K_UNKNOWN, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * Add support for comment formatting - */ - public void test554() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.comment_format_line_comment_starting_on_first_column = true; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.tab_size = 4; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test554", "A.java", CodeFormatter.K_SINGLE_LINE_COMMENT, false);//$NON-NLS-1$ //$NON-NLS-2$ - - runTest(codeFormatter, "test554", "A.java", CodeFormatter.K_UNKNOWN, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=73104 - public void test555() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.MIXED; - preferences.indentation_size = 4; - preferences.tab_size = 8; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test555", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /* - * Empty array initializer formatting - */ - public void test556() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.tab_size = 4; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test556", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /* - * Empty array initializer formatting - */ - public void test557() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_size = 4; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.keep_empty_array_initializer_on_one_line = true; - preferences.insert_space_between_empty_braces_in_array_initializer = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test557", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * Initial test for bug 89302 - * This test was deprecated in order to test backward compatibility - * after the integration of the fix for bug 122247 - * @deprecated - * @see bug 122247 - */ - public void test558() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_ENUM_CONSTANT, null); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD, null); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD, null); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE, null); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE, null); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER, null); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, null); - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247: use deprecated option - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION, JavaCore.DO_NOT_INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_size = 4; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.insert_space_after_comma_in_enum_declarations = false; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test558", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - /** - * Initial test for bug 89302 - * This test was deprecated in order to test backward compatibility - * after the integration of the fix for bug 122247 - * @deprecated - * @see bug 122247 - */ - public void test559() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_ENUM_CONSTANT, null); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD, null); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD, null); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE, null); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE, null); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER, null); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, null); - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247: use deprecated option - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION, JavaCore.DO_NOT_INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_size = 4; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.insert_space_after_comma_in_enum_declarations = true; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test559", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=81497 - public void test560() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_size = 4; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.brace_position_for_array_initializer = DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED; - preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.brace_position_for_method_declaration = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.brace_position_for_block = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.keep_empty_array_initializer_on_one_line = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test560", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=81497 - public void test561() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.tab_size = 4; - preferences.brace_position_for_array_initializer = DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED; - preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.brace_position_for_method_declaration = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.brace_position_for_block = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.keep_empty_array_initializer_on_one_line = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test561", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=89318 - public void test562() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.tab_size = 4; - preferences.insert_space_after_closing_angle_bracket_in_type_arguments = false; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test562", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=89318 - public void test563() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_size = 4; - preferences.tab_size = 4; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.insert_space_after_closing_angle_bracket_in_type_arguments = true; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test563", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=89299 - public void test564() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.tab_size = 4; - preferences.brace_position_for_array_initializer = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.brace_position_for_method_declaration = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.brace_position_for_block = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.keep_empty_array_initializer_on_one_line = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test564", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /*// https://bugs.eclipse.org/bugs/show_bug.cgi?id=49896 - public void test565() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION, - DefaultCodeFormatterConstants.createAlignmentValue(true, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.use_tabs_only_for_leading_indentations = true; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test565", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - }*/ - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=73658 - public void test566() { - Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_size = 4; - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.brace_position_for_enum_constant = DefaultCodeFormatterConstants.NEXT_LINE; - preferences.brace_position_for_enum_declaration = DefaultCodeFormatterConstants.NEXT_LINE; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test566", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=49896 - public void test567() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.use_tabs_only_for_leading_indentations = true; - preferences.page_width = 35; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test567", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=49896 - public void test568() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.indentation_size = 4; - preferences.tab_size = 4; - preferences.tab_char = DefaultCodeFormatterOptions.MIXED; - preferences.use_tabs_only_for_leading_indentations = true; - preferences.page_width = 35; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test568", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=49896 - public void test569() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.indentation_size = 4; - preferences.tab_size = 4; - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.use_tabs_only_for_leading_indentations = false; - preferences.page_width = 40; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test569", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=77809 - public void test570() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test570", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=77809 - public void test571() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS, - DefaultCodeFormatterConstants.createAlignmentValue(true, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test571", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90213 - public void test572() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.insert_space_after_opening_brace_in_array_initializer = false; - preferences.insert_space_before_closing_brace_in_array_initializer = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test572", "A.java", CodeFormatter.K_STATEMENTS, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90213 - public void test573() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test573", "A.java", CodeFormatter.K_STATEMENTS, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=91238 - public void test574() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=102780 - preferences.comment_indent_root_tags = false; - preferences.comment_align_tags_descriptions_grouped = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test574", "A.java", CodeFormatter.K_JAVA_DOC, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * Initial test for bug 77809 - * This test was deprecated in order to test backward compatibility - * after the integration of the fix for bug 122247 - * @deprecated - * @see bug 122247 - */ - - public void test575() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_ENUM_CONSTANT, null); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD, null); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD, null); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE, null); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE, null); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER, null); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, null); - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247: use deprecated option - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION, JavaCore.INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test575", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=95431 - public void test576() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test576", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=98037 - public void test577() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test577", "A.java", CodeFormatter.K_UNKNOWN, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=98037 - public void test578() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test578", "A.java", CodeFormatter.K_UNKNOWN, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=98139 - public void test579() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test579", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=98139 - public void test580() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test580", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=99084 - public void test581() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test581", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=99084 - public void test582() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.insert_space_after_closing_angle_bracket_in_type_arguments = false; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test582", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=100062 - public void test583() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test583", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=49896 - public void test584() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, DefaultCodeFormatterConstants.TRUE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, DefaultCodeFormatterConstants.MIXED); - options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "65"); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test584", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=49896 - public void test585() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, DefaultCodeFormatterConstants.TRUE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, DefaultCodeFormatterConstants.MIXED); - options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "80"); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test585", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=49896 - public void test586() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, DefaultCodeFormatterConstants.TRUE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "65"); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test586", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=49896 - public void test587() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, DefaultCodeFormatterConstants.TRUE); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "80"); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test587", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=101230 - public void test588() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test588", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=104796 - public void test589() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test589", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=103706 - public void test590() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES, DefaultCodeFormatterConstants.TRUE); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test590", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=103706 - public void test591() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES, DefaultCodeFormatterConstants.FALSE); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test591", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=98089 - public void test592() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "60"); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); - options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test592", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=71766 - public void test593() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ASSIGNMENT, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NO_SPLIT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test593", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=71766 - public void test594() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ASSIGNMENT, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test594", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=71766 - public void test595() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ASSIGNMENT, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test595", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=71766 - public void test596() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ASSIGNMENT, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test596", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=87193 - public void test597() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, DefaultCodeFormatterConstants.MIXED); - options.put(DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, DefaultCodeFormatterConstants.TRUE); - options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "60"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test597", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=87193 - public void test598() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - options.put(DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, DefaultCodeFormatterConstants.TRUE); - options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "60"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test598", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=87193 - public void test599() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - options.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION, "1"); - options.put(DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, DefaultCodeFormatterConstants.TRUE); - options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "60"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test599", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - // test Scribe2.hasNLSTag() - public void test600() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test600", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - // Binary expression - public void test601() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - String alignment = DefaultCodeFormatterConstants.createAlignmentValue(true, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT); - options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ADDITIVE_OPERATOR, alignment); - options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_MULTIPLICATIVE_OPERATOR, alignment); - options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_LOGICAL_OPERATOR, alignment); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - options.put(DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, DefaultCodeFormatterConstants.TRUE); - options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "60"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test601", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=108916 - public void test605() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS, - DefaultCodeFormatterConstants.createAlignmentValue( - true, - DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, - DefaultCodeFormatterConstants.INDENT_DEFAULT)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test605", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=110304 - public void test606() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_RETURN, JavaCore.DO_NOT_INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test606", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=111270 - public void test607() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test607", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=111270 - public void test608() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test608", "A.java", CodeFormatter.K_JAVA_DOC, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=116858 - public void test609() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.indent_switchstatements_compare_to_cases = true; - preferences.indent_switchstatements_compare_to_switch = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test609", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=122914 - */ - public void test610() { - String resourcePath = getResource("test610", "formatter.xml"); - Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "mhdk"); - assertNotNull("No preferences", options); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test610", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=111446 - */ - public void test611() { - { - // only tabs, indentation size = 4, tab size = 4 - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.tab_size = 4; - preferences.indentation_size = 4; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - assertEquals("Wrong indentation string", "\t", codeFormatter.createIndentationString(1)); - assertEquals("Wrong indentation string", "\t\t", codeFormatter.createIndentationString(2)); - assertEquals("Wrong indentation string", "\t\t\t", codeFormatter.createIndentationString(3)); - } - { - // only tabs, indentation size = 8, tab size = 8 - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.TAB; - preferences.tab_size = 8; - preferences.indentation_size = 8; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - assertEquals("Wrong indentation string", "\t", codeFormatter.createIndentationString(1)); - assertEquals("Wrong indentation string", "\t\t", codeFormatter.createIndentationString(2)); - assertEquals("Wrong indentation string", "\t\t\t", codeFormatter.createIndentationString(3)); - } - { - // only spaces, indentation size = 2, tab size = 4 - // tab size is ignored - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - preferences.tab_size = 4; - preferences.indentation_size = 2; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - assertEquals("Wrong indentation string", " ", codeFormatter.createIndentationString(1)); - assertEquals("Wrong indentation string", " ", codeFormatter.createIndentationString(2)); - assertEquals("Wrong indentation string", " ", codeFormatter.createIndentationString(3)); - } - { - // mixed, indentation size = 4 tab size = 2 - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.MIXED; - preferences.tab_size = 2; - preferences.indentation_size = 4; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - assertEquals("Wrong indentation string", "\t\t", codeFormatter.createIndentationString(1)); - assertEquals("Wrong indentation string", "\t\t\t\t", codeFormatter.createIndentationString(2)); - } - { - // mixed, indentation size = 2, tab size = 4 - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.tab_char = DefaultCodeFormatterOptions.MIXED; - preferences.tab_size = 4; - preferences.indentation_size = 2; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - assertEquals("Wrong indentation string", " ", codeFormatter.createIndentationString(1)); - assertEquals("Wrong indentation string", "\t", codeFormatter.createIndentationString(2)); - assertEquals("Wrong indentation string", "\t ", codeFormatter.createIndentationString(3)); - } - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=126625 - public void test612() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.indent_body_declarations_compare_to_annotation_declaration_header = false; - preferences.indent_body_declarations_compare_to_type_header = true; - preferences.keep_annotation_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test612", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=126625 - public void test613() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.indent_body_declarations_compare_to_annotation_declaration_header = true; - preferences.indent_body_declarations_compare_to_type_header = false; - preferences.keep_annotation_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test613", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=128848 - public void test614() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test614", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=128848 - public void test615() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test615", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=128848 - public void test616() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test616", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=131013 - public void test617() { - String resourcePath = getResource("test617", "formatter.xml"); - Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "JRK"); - assertNotNull("No preferences", options); - options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_STRING_CONCATENATION, - DefaultCodeFormatterConstants.createAlignmentValue( - true, - DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, - DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test617", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=137224 - public void test618() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test618", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=137224 - public void test619() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test619", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=139291 - public void test620() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS, JavaCore.DO_NOT_INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test620", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=139291 - public void test621() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS, JavaCore.DO_NOT_INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test621", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=148370 - public void test622() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test622", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=148370 - public void test623() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test623", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=148370 - public void test624() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test624", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=102728 - public void test625() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_STRING_CONCATENATION, - DefaultCodeFormatterConstants.createAlignmentValue( - true, - DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, - DefaultCodeFormatterConstants.INDENT_DEFAULT)); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test625", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=152725 - public void test626() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test626", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=158267 - public void test627() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test627", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=158267 - public void test628() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test628", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=158267 - public void test629() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test629", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=158267 - public void test630() { - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipseDefaultSettings()); - preferences.insert_space_after_opening_paren_in_parenthesized_expression = true; - preferences.insert_space_before_closing_paren_in_parenthesized_expression = true; - preferences.insert_space_before_parenthesized_expression_in_throw = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test630", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=158267 - public void test631() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_THROW, JavaCore.INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test631", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=158267 - public void test632() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_RETURN, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_THROW, JavaCore.DO_NOT_INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test632", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=165210 - public void test633() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BETWEEN_IMPORT_GROUPS, "3"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test633", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=165210 - public void test634() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BETWEEN_IMPORT_GROUPS, "1"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test634", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=165210 - public void test635() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BETWEEN_IMPORT_GROUPS, "1"); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AFTER_IMPORTS, "0"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test635", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=165210 - public void test636() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BETWEEN_IMPORT_GROUPS, "3"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test636", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=165210 - public void test637() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BETWEEN_IMPORT_GROUPS, "2"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test637", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=165210 - public void test638() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BETWEEN_IMPORT_GROUPS, "1"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test638", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=165210 - public void test639() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BETWEEN_IMPORT_GROUPS, "2"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test639", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=165210 - public void test640() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BETWEEN_IMPORT_GROUPS, "1"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test640", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=168109 - public void test641() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, DefaultCodeFormatterConstants.MIXED); - options.put(DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, DefaultCodeFormatterConstants.TRUE); - options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "36"); - options.put(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, "2"); - options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test641", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=166962 - public void test642() { - String resourcePath = getResource("test642", "formatter.xml"); - Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "Visionnaire"); - assertNotNull("No preferences", options); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test642", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=171634 - public void test643() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING, JavaCore.INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test643", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=171634 - public void test644() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING, JavaCore.INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test644", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=171634 - public void test645() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING, JavaCore.INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test645", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=171634 - public void test646() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING, JavaCore.DO_NOT_INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test646", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=171634 - public void test647() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING, JavaCore.DO_NOT_INSERT); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test647", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=171634 - public void test648() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING, JavaCore.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "0"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test648", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=171634 - public void test649() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING, JavaCore.INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "0"); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test649", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=172848 - public void test650() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test650", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=172848 - public void test651() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test651", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=172848 - public void test652() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test652", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=172848 - public void test653() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test653", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=172848 - public void test654() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test654", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=172848 - public void test655() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test655", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test656() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.indent_empty_lines = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test656", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - public void test657() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.indent_empty_lines = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test657", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=20793 - public void test658() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.never_indent_block_comments_on_first_column = false; - preferences.never_indent_line_comments_on_first_column = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test658", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=20793 - public void test659() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.never_indent_block_comments_on_first_column = true; - preferences.never_indent_line_comments_on_first_column = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test659", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=20793 - public void test660() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.never_indent_block_comments_on_first_column = false; - preferences.never_indent_line_comments_on_first_column = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test660", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=20793 - public void test661() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.never_indent_block_comments_on_first_column = true; - preferences.never_indent_line_comments_on_first_column = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test661", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=20793 - public void test662() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.never_indent_block_comments_on_first_column = true; - preferences.never_indent_line_comments_on_first_column = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test662", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=20793 - public void test663() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.never_indent_block_comments_on_first_column = true; - preferences.never_indent_line_comments_on_first_column = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test663", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=79068 - */ - public void test664() { - Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, - DefaultCodeFormatterConstants.createAlignmentValue( - true, - DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, - DefaultCodeFormatterConstants.INDENT_BY_ONE - )); - options.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_STRING_CONCATENATION, - DefaultCodeFormatterConstants.createAlignmentValue( - false, - DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, - DefaultCodeFormatterConstants.INDENT_BY_ONE - )); - options.put(DefaultCodeFormatterConstants.FORMATTER_WRAP_BEFORE_STRING_CONCATENATION, DefaultCodeFormatterConstants.FALSE); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test664", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=49314 - public void test665() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.never_indent_block_comments_on_first_column = true; - preferences.never_indent_line_comments_on_first_column = true; - preferences.comment_format_block_comment = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test665", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=172324 - public void test666() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.never_indent_block_comments_on_first_column = true; - preferences.never_indent_line_comments_on_first_column = true; - preferences.comment_format_block_comment = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test666", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=192285 - public void test667() { - Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test667", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=198362 - public void test668() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test668", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203020 - public void test669() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test669", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203020 - public void test670() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test670", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 - public void test671() { - /* old version - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(59, 20), - new Region(101, 20) - }; - runTest(codeFormatter, "test671", "A.java", CodeFormatter.K_COMPILATION_UNIT, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - */ - String source = - "public class A {\n" + - " public static void main(String[] args) {\n" + - "[# int a = 1;#]\n" + - " int b = 2;\n" + - "[# int c = 3;#]\n" + - " }\n" + - "}\n"; - formatSource(source, - "public class A {\n" + - " public static void main(String[] args) {\n" + - " int a = 1;\n" + - " int b = 2;\n" + - " int c = 3;\n" + - " }\n" + - "}\n", - CodeFormatter.K_COMPILATION_UNIT, - 0 /*no indentation*/, - true /*repeat formatting twice*/ - ); - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 - public void test672() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(0, 18), - new Region(38, 18) - }; - runTest(codeFormatter, "test672", "A.java", CodeFormatter.K_STATEMENTS, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 - public void test673() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(0, 9), - new Region(19, 19) - }; - runTest(codeFormatter, "test673", "A.java", CodeFormatter.K_EXPRESSION, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 - public void test674() { - /* old version - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(44, 126), - new Region(276, 54) - }; - runTest(codeFormatter, "test674", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - */ - String source = - "public class A {\n" + - " \n" + - " \n" + - " private class Inner1 {[#\n" + - " \n" + - " \n" + - " void bar () { }\n" + - " \n" + - " void i()\n" + - " {\n" + - " \n" + - " }\n" + - " #]}\n" + - " \n" + - " \n" + - " private class Inner2 {\n" + - " void xy() {\n" + - " \n" + - " }\n" + - " }\n" + - "}\n" + - "class B {[#\n" + - " private void foo() {\n" + - " \n" + - " }\n" + - "#]}\n"; - formatSource(source, - "public class A {\n" + - " \n" + - " \n" + - " private class Inner1 {\n" + - "\n" + - " void bar() {\n" + - " }\n" + - "\n" + - " void i() {\n" + - "\n" + - " }\n" + - " }\n" + - " \n" + - " \n" + - " private class Inner2 {\n" + - " void xy() {\n" + - " \n" + - " }\n" + - " }\n" + - "}\n" + - "class B {\n" + - " private void foo() {\n" + - "\n" + - " }\n" + - "}\n", - CodeFormatter.K_CLASS_BODY_DECLARATIONS, - 0 /*no indentation*/, - true /*repeat formatting twice*/ - ); - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 - // NOT_FIXED_YET: https://bugs.eclipse.org/bugs/show_bug.cgi?id=204091 - public void _test675() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(10, 20), - new Region(50, 14), - new Region(68, 25) - }; - runTest(codeFormatter, "test675", "A.java", CodeFormatter.K_MULTI_LINE_COMMENT, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 - // NOT_FIXED_YET: https://bugs.eclipse.org/bugs/show_bug.cgi?id=204091 - public void _test676() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(3, 16), - new Region(31, 16) - }; - runTest(codeFormatter, "test676", "A.java", CodeFormatter.K_SINGLE_LINE_COMMENT, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 - // NOT_FIXED_YET: https://bugs.eclipse.org/bugs/show_bug.cgi?id=204091 - public void _test677() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(4, 16), - new Region(32, 16) - }; - runTest(codeFormatter, "test677", "A.java", CodeFormatter.K_JAVA_DOC, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 - public void test678() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(59, 20), - new Region(101, 20) - }; - runTest(codeFormatter, "test671", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 - public void test679() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(0, 18), - new Region(38, 18) - }; - runTest(codeFormatter, "test672", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 - public void test680() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(0, 9), - new Region(19, 19) - }; - runTest(codeFormatter, "test673", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 - public void test681() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(44, 126), - new Region(276, 54) - }; - runTest(codeFormatter, "test674", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - -//https://bugs.eclipse.org/bugs/show_bug.cgi?id=204091 -// -// // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 -// public void test682() { -// final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); -// DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); -// DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); -// IRegion[] regions = new IRegion[] { -// new Region(10, 20), -// new Region(50, 14), -// new Region(68, 25) -// }; -// runTest(codeFormatter, "test675", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ -// } -// -// // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 -// public void test683() { -// final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); -// DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); -// DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); -// IRegion[] regions = new IRegion[] { -// new Region(3, 16), -// new Region(31, 16) -// }; -// runTest(codeFormatter, "test676", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ -// } -// -// // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 -// public void test684() { -// final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); -// DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); -// DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); -// IRegion[] regions = new IRegion[] { -// new Region(4, 16), -// new Region(32, 16) -// }; -// runTest(codeFormatter, "test677", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ -// } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 - public void test685() { - /* old version - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(18, 35) - }; - runTest(codeFormatter, "test685", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - */ - String source = - "public class A {\n" + - " [# int i=1; #] \n" + - "}\n"; - // Note that whitespaces outside the region are kept after the formatting - // This is intentional since fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=234583 - // The formatter should not touch code outside the given region(s)... - formatSource(source, - "public class A {\n" + - " int i = 1; \n" + - "}\n", - CodeFormatter.K_UNKNOWN, - 0 /*no indentation*/, - true /*repeat formatting twice*/ - ); - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 - public void test686() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test685", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 - public void test687() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(17, 25) - }; - runTest(codeFormatter, "test687", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 - public void test688a() { - /* old version - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(18, 48) - }; - runTest(codeFormatter, "test688", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - */ - String source = - "public class A {\n" + - " [# int i=1; \n" + - "}#]\n"; - // Note that whitespaces outside the region are kept after the formatting - // This is intentional since fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=234583 - // The formatter should not touch code outside the given region(s)... - formatSource(source, - "public class A {\n" + - " int i = 1;\n" + - "}\n", - CodeFormatter.K_UNKNOWN, - 0 /*no indentation*/, - true /*repeat formatting twice*/ - ); - } - - public void test688b() { - /* old version - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(18, 49) - }; - runTest(codeFormatter, "test688", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - */ - String source = - "public class A {\n" + - " [# int i=1; \n" + - "}\n#]"; - // Note that whitespaces outside the region are kept after the formatting - // This is intentional since fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=234583 - // The formatter should not touch code outside the given region(s)... - formatSource(source, - "public class A {\n" + - " int i = 1;\n" + - "}\n" - ); - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 - public void test689() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.line_separator = "\n";//$NON-NLS-1$ - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(31, 23) - }; - runTest(codeFormatter, "test689", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 - public void test690() { - /* old version - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.line_separator = "\r";//$NON-NLS-1$ - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(31, 23) - }; - runTest(codeFormatter, "test689", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\r");//$NON-NLS-1$ //$NON-NLS-2$ - */ - this.formatterPrefs.line_separator = "\r";//$NON-NLS-1$ - String source = - "package pkg1;\n" + - "public class A {\n" + - "[# int i = 1; #]\n" + - "\n" + - "}\n"; - // Note that whitespaces outside the region are kept after the formatting - // This is intentional since fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=234583 - // The formatter should not touch code outside the given region(s)... - formatSource(source, - "package pkg1;\n" + - "public class A {\n" + - " int i = 1;\n" + - "\n" + - "}\n", - CodeFormatter.K_UNKNOWN, - 0 /*no indentation*/, - true /*repeat formatting twice*/ - ); - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 - public void test691() { - /* old version - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.line_separator = "\r\n";//$NON-NLS-1$ - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(31, 22) - }; - runTest(codeFormatter, "test689", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\r\n");//$NON-NLS-1$ //$NON-NLS-2$ - */ - this.formatterPrefs.line_separator = "\r\n";//$NON-NLS-1$ - String source = - "package pkg1;\n" + - "public class A {\n" + - "[# int i = 1; #] \n" + - "\n" + - "}\n"; - // Note that whitespaces outside the region are kept after the formatting - // This is intentional since fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=234583 - // The formatter should not touch code outside the given region(s)... - formatSource(source, - "package pkg1;\n" + - "public class A {\n" + - " int i = 1; \n" + - "\n" + - "}\n", - CodeFormatter.K_UNKNOWN, - 0 /*no indentation*/, - true /*repeat formatting twice*/ - ); - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 - public void test692() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.page_width = 999; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(83, 41) - }; - runTest(codeFormatter, "test692", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=210922 - public void test693() { - final class MyRegion implements IRegion { - public int getLength() { - return 0; - } - public int getOffset() { - return 0; - } - } - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.line_separator = "\n";//$NON-NLS-1$ - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new MyRegion() - }; - runTest(codeFormatter, "test693", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=213283 - public void test694a() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.line_separator = "\n";//$NON-NLS-1$ - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(33, 32) - }; - runTest(codeFormatter, "test694", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=213283 - public void test694b() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.line_separator = "\n";//$NON-NLS-1$ - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(33, 33) - }; - runTest(codeFormatter, "test694", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=213284 - public void test695() { - /* old version - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.line_separator = "\n";//$NON-NLS-1$ - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(59, 1) - }; - runTest(codeFormatter, "test695", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - */ - String source = - "package test1;\n" + - "public class A {\n" + - "\n" + - " public int field;\n" + - "[#\n#]" + - "\n" + - "}\r\n"; - // Note that whitespaces outside the region are kept after the formatting - // This is intentional since fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=234583 - // The formatter should not touch code outside the given region(s)... - formatSource(source, - "package test1;\n" + - "public class A {\n" + - "\n" + - " public int field;\n" + - "\n" + - "}\r\n", - CodeFormatter.K_UNKNOWN, - 0 /*no indentation*/, - true /*repeat formatting twice*/ - ); - } - - // variation on bugs 208541, 213283, 213284 - public void test696a() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.line_separator = "\n";//$NON-NLS-1$ - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(17, 56) - }; - runTest(codeFormatter, "test696a", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // variation on bugs 208541, 213283, 213284 - public void test696b() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.line_separator = "\n";//$NON-NLS-1$ - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(17, 57) - }; - runTest(codeFormatter, "test696b", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // variation on bugs 208541, 213283, 213284 - public void test697a() { - /* old version - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.line_separator = "\n";//$NON-NLS-1$ - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(17, 55) // end of line selection - }; - runTest(codeFormatter, "test697", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - */ - String source = - "public class A {\n" + - "[# \n" + - " \n" + - " \n" + - " int i = 1; #]\n" + - "\n" + - "\n" + - "\n" + - "}\n" + - ""; - // Note that whitespaces outside the region are kept after the formatting - // This is intentional since fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=234583 - // The formatter should not touch code outside the given region(s)... - formatSource(source, - "public class A {\n" + - "\n" + - " int i = 1;\n" + - "\n" + - "\n" + - "\n" + - "}\n", - CodeFormatter.K_UNKNOWN, - 0 /*no indentation*/, - true /*repeat formatting twice*/ - ); - } - - // variation on bugs 208541, 213283, 213284 - public void test697b() { - /* old version - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.line_separator = "\n";//$NON-NLS-1$ - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(17, 56) // end of line selection + 1 - }; - runTest(codeFormatter, "test697", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - */ - String source = - "public class A {\n" + - "[# \n" + - " \n" + - " \n" + - " int i = 1; \n" + - "#]\n" + - "\n" + - "\n" + - "}\n" + - ""; - // Note that whitespaces outside the region are kept after the formatting - // This is intentional since fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=234583 - // The formatter should not touch code outside the given region(s)... - formatSource(source, - "public class A {\n" + - "\n" + - " int i = 1;\n" + - "\n" + - "\n" + - "}\n", - CodeFormatter.K_UNKNOWN, - 0 /*no indentation*/, - true /*repeat formatting twice*/ - ); - } - - // variation on bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 -// public void test698() { -// final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); -// DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); -// preferences.line_separator = "\n";//$NON-NLS-1$ -// DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); -// IRegion[] regions = new IRegion[] { -// new Region(17, 40) // partial line selection -// }; -// runTest(codeFormatter, "test698", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ -// } - - // variation on bugs 208541, 213283, 213284 - public void test699() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.line_separator = "\n";//$NON-NLS-1$ - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(0, 78) // nothing selected --> format all - }; - runTest(codeFormatter, "test699", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 - public void test700() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.line_separator = "\n";//$NON-NLS-1$ - preferences.insert_new_line_after_annotation_on_parameter = false; // override default - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(0, 221) // nothing selected --> format all - }; - runTest(codeFormatter, "test700", "X.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 - public void test701() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.line_separator = "\n";//$NON-NLS-1$ - preferences.insert_new_line_after_annotation_on_parameter = true; - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(0, 221) // nothing selected --> format all - }; - runTest(codeFormatter, "test701", "X.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 - public void test702() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.line_separator = "\n";//$NON-NLS-1$ - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(0, 86) // nothing selected --> format all - }; - runTest(codeFormatter, "test702", "X.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 - public void test703() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.line_separator = "\n";//$NON-NLS-1$ - preferences.insert_new_line_after_annotation_on_parameter = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(0, 86) // nothing selected --> format all - }; - runTest(codeFormatter, "test703", "X.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 - public void test704() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.line_separator = "\n";//$NON-NLS-1$ - preferences.insert_new_line_after_annotation_on_type = false; - preferences.insert_new_line_after_annotation_on_field = false; - preferences.insert_new_line_after_annotation_on_method = false; - preferences.insert_new_line_after_annotation_on_package = false; - preferences.insert_new_line_after_annotation_on_parameter = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(0, 86) // nothing selected --> format all - }; - runTest(codeFormatter, "test704", "X.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 - public void test705() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.line_separator = "\n";//$NON-NLS-1$ - preferences.insert_new_line_after_annotation_on_type = false; - preferences.insert_new_line_after_annotation_on_field = false; - preferences.insert_new_line_after_annotation_on_method = false; - preferences.insert_new_line_after_annotation_on_package = false; - preferences.insert_new_line_after_annotation_on_parameter = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(0, 86) // nothing selected --> format all - }; - runTest(codeFormatter, "test705", "X.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 - // test706 through test712 format the same CU with different combination of annotation formatting options - public void test706() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.line_separator = "\n";//$NON-NLS-1$ - preferences.insert_new_line_after_annotation_on_type = false; - preferences.alignment_for_annotations_on_type = Alignment.M_NO_ALIGNMENT; - preferences.insert_new_line_after_annotation_on_field = false; - preferences.alignment_for_annotations_on_field = Alignment.M_NO_ALIGNMENT; - preferences.insert_new_line_after_annotation_on_method = false; - preferences.alignment_for_annotations_on_method = Alignment.M_NO_ALIGNMENT; - preferences.insert_new_line_after_annotation_on_package = false; - preferences.alignment_for_annotations_on_package = Alignment.M_NO_ALIGNMENT; - preferences.insert_new_line_after_annotation_on_parameter = true; - preferences.insert_new_line_after_annotation_on_local_variable = false; - preferences.alignment_for_annotations_on_local_variable = Alignment.M_NO_ALIGNMENT; - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test706", "X.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 - public void test707() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.insert_new_line_after_annotation_on_type = true; - preferences.insert_new_line_after_annotation_on_field = true; - preferences.insert_new_line_after_annotation_on_method = true; - preferences.insert_new_line_after_annotation_on_package = true; - preferences.insert_new_line_after_annotation_on_parameter = true; - preferences.insert_new_line_after_annotation_on_local_variable = false; - preferences.alignment_for_annotations_on_local_variable = Alignment.M_NO_ALIGNMENT; - preferences.line_separator = "\n";//$NON-NLS-1$ - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test707", "X.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 - public void test708() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.line_separator = "\n";//$NON-NLS-1$ - preferences.insert_new_line_after_annotation_on_type = true; - preferences.insert_new_line_after_annotation_on_field = true; - preferences.insert_new_line_after_annotation_on_method = true; - preferences.insert_new_line_after_annotation_on_package = true; - preferences.insert_new_line_after_annotation_on_parameter = false; - preferences.insert_new_line_after_annotation_on_local_variable = false; - preferences.alignment_for_annotations_on_local_variable = Alignment.M_NO_ALIGNMENT; - setPageWidth80(preferences); - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test708", "X.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 - public void test709() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.insert_new_line_after_annotation_on_type = false; - preferences.alignment_for_annotations_on_type = Alignment.M_NO_ALIGNMENT; - preferences.insert_new_line_after_annotation_on_field = false; - preferences.alignment_for_annotations_on_field = Alignment.M_NO_ALIGNMENT; - preferences.insert_new_line_after_annotation_on_method = false; - preferences.alignment_for_annotations_on_method = Alignment.M_NO_ALIGNMENT; - preferences.insert_new_line_after_annotation_on_package = false; - preferences.alignment_for_annotations_on_package = Alignment.M_NO_ALIGNMENT; - preferences.insert_new_line_after_annotation_on_parameter = false; - preferences.insert_new_line_after_annotation_on_local_variable = false; - preferences.alignment_for_annotations_on_local_variable = Alignment.M_NO_ALIGNMENT; - preferences.line_separator = "\n";//$NON-NLS-1$ - setPageWidth80(preferences); - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test709", "X.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 - public void test710() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.insert_new_line_after_annotation_on_type = false; - preferences.alignment_for_annotations_on_type = Alignment.M_NO_ALIGNMENT; - preferences.insert_new_line_after_annotation_on_field = false; - preferences.alignment_for_annotations_on_field = Alignment.M_NO_ALIGNMENT; - preferences.insert_new_line_after_annotation_on_method = false; - preferences.alignment_for_annotations_on_method = Alignment.M_NO_ALIGNMENT; - preferences.insert_new_line_after_annotation_on_package = false; - preferences.alignment_for_annotations_on_package = Alignment.M_NO_ALIGNMENT; - preferences.insert_new_line_after_annotation_on_parameter = true; - preferences.insert_new_line_after_annotation_on_local_variable = true; - preferences.line_separator = "\n";//$NON-NLS-1$ - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test710", "X.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 - public void test711() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.insert_new_line_after_annotation_on_type = false; - preferences.alignment_for_annotations_on_type = Alignment.M_NO_ALIGNMENT; - preferences.insert_new_line_after_annotation_on_field = false; - preferences.alignment_for_annotations_on_field = Alignment.M_NO_ALIGNMENT; - preferences.insert_new_line_after_annotation_on_method = false; - preferences.alignment_for_annotations_on_method = Alignment.M_NO_ALIGNMENT; - preferences.insert_new_line_after_annotation_on_package = false; - preferences.alignment_for_annotations_on_package = Alignment.M_NO_ALIGNMENT; - preferences.insert_new_line_after_annotation_on_parameter = false; - preferences.insert_new_line_after_annotation_on_local_variable = true; - preferences.line_separator = "\n";//$NON-NLS-1$ - setPageWidth80(preferences); - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test711", "X.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 - public void test712() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.line_separator = "\n";//$NON-NLS-1$ - setPageWidth80(preferences); - // use defaults - Hashtable javaCoreOptions = JavaCore.getOptions(); - try { - Hashtable newJavaCoreOptions = JavaCore.getOptions(); - newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - JavaCore.setOptions(newJavaCoreOptions); - - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test712", "X.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } finally { - JavaCore.setOptions(javaCoreOptions); - } - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=222182 - public void test713() { - String resourcePath = getResource("test713", "formatter.xml"); - Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "Dani"); - assertNotNull("No preferences", options); - /* old version - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test713", "A.java", CodeFormatter.K_COMPILATION_UNIT, 0, false, 76, 27);//$NON-NLS-1$ //$NON-NLS-2$ - */ - this.formatterPrefs = new DefaultCodeFormatterOptions(options); - String source = - "package pack;\n" + - "\n" + - "public class A {\n" + - " /**\n" + - " * @see A.Inner\n" + - " */\n" + - "[# public class Inner { }\n" + - "#]}"; - formatSource(source, - "package pack;\n" + - "\n" + - "public class A {\n" + - " /**\n" + - " * @see A.Inner\n" + - " */\n" + - " public class Inner {\n" + - " }\n" + - "}" - ); - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=102780 - public void test714() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - // verify that the javadoc is indented, though the formatting of javadoc comments is disabled - preferences.comment_format_javadoc_comment = false; - setPageWidth80(preferences); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test714", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=244477 - public void test715() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.keep_empty_array_initializer_on_one_line = true; - preferences.insert_space_before_comma_in_array_initializer = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test715", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=244477 - public void test716() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.keep_empty_array_initializer_on_one_line = true; - preferences.insert_space_before_comma_in_array_initializer = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test716", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=244477 - public void test717() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.keep_empty_array_initializer_on_one_line = false; - preferences.insert_space_before_comma_in_array_initializer = false; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test717", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=244477 - public void test718() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.keep_empty_array_initializer_on_one_line = false; - preferences.insert_space_before_comma_in_array_initializer = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test718", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=250753 - public void test719() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.keep_empty_array_initializer_on_one_line = false; - preferences.insert_space_between_empty_braces_in_array_initializer = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - runTest(codeFormatter, "test719", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ - } -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=270983 -public void test720() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test720", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ -} -//https://bugs.eclipse.org/bugs/show_bug.cgi?id=270983 -public void test721() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test721", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ -} -//https://bugs.eclipse.org/bugs/show_bug.cgi?id=283133 -public void test722() { - try { - assertEquals("Should be 0", 0, IndentManipulation.measureIndentUnits("", 1, 0)); - } catch (IllegalArgumentException e) { - assertTrue("Should not happen", false); - } -} -//https://bugs.eclipse.org/bugs/show_bug.cgi?id=284679 -public void test723() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - Map compilerOptions = new HashMap(); - compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); - runTest(codeFormatter, "test723", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=150741 -public void test724() { - this.formatterPrefs.insert_new_line_after_label = true; - String source = - "public class X {\n" + - " public static void main(String[] args) {\n" + - " LABEL:for (int i = 0; i < 10; i++) {\n" + - " }\n" + - " }\n" + - "\n" + - "}\n" + - ""; - formatSource(source, - "public class X {\n" + - " public static void main(String[] args) {\n" + - " LABEL:\n" + - " for (int i = 0; i < 10; i++) {\n" + - " }\n" + - " }\n" + - "\n" + - "}\n" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=308000 -public void test725() { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6); - String source = - "@Deprecated package pack;\n" + - "public class Test {\n" + - " @Deprecated Test(String s) {}\n" + - " @Deprecated String label;\n" + - " @Deprecated void foo() {}\n" + - " @Deprecated interface I {}\n" + - "}\n"; - formatSource(source, - "@Deprecated\n" + - "package pack;\n" + - "\n" + - "public class Test {\n" + - " @Deprecated\n" + - " Test(String s) {\n" + - " }\n" + - "\n" + - " @Deprecated\n" + - " String label;\n" + - "\n" + - " @Deprecated\n" + - " void foo() {\n" + - " }\n" + - "\n" + - " @Deprecated\n" + - " interface I {\n" + - " }\n" + - "}\n" - ); -} -public void test726() { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE, DefaultCodeFormatterConstants.FALSE); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD, DefaultCodeFormatterConstants.FALSE); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD, DefaultCodeFormatterConstants.FALSE); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE, DefaultCodeFormatterConstants.FALSE); - String source = - "@Deprecated package pack;\n" + - "public class Test {\n" + - " @Deprecated Test(String s) {}\n" + - " @Deprecated String label;\n" + - " @Deprecated void foo() {}\n" + - " @Deprecated interface I {}\n" + - "}\n"; - formatSource(source, - "@Deprecated package pack;\n" + - "\n" + - "public class Test {\n" + - " @Deprecated Test(String s) {\n" + - " }\n" + - "\n" + - " @Deprecated String label;\n" + - "\n" + - " @Deprecated void foo() {\n" + - " }\n" + - "\n" + - " @Deprecated interface I {\n" + - " }\n" + - "}\n" - ); -} -/** - * @deprecated Use a deprecated formatter option. - */ -public void test727() { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, DefaultCodeFormatterConstants.TRUE); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD, DefaultCodeFormatterConstants.FALSE); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD, DefaultCodeFormatterConstants.FALSE); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE, DefaultCodeFormatterConstants.FALSE); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE, DefaultCodeFormatterConstants.FALSE); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER, DefaultCodeFormatterConstants.FALSE); - String source = - "@Deprecated package pack;\n" + - "public class Test {\n" + - " @Deprecated Test(String s) {}\n" + - " @Deprecated String label;\n" + - " @Deprecated void foo() {}\n" + - " @Deprecated interface I {}\n" + - "}\n"; - formatSource(source, - "@Deprecated package pack;\n" + - "\n" + - "public class Test {\n" + - " @Deprecated Test(String s) {\n" + - " }\n" + - "\n" + - " @Deprecated String label;\n" + - "\n" + - " @Deprecated void foo() {\n" + - " }\n" + - "\n" + - " @Deprecated interface I {\n" + - " }\n" + - "}\n" - ); -} - -/** - * @deprecated Use a deprecated formatter option. - */ -public void test728() { - this.formatterPrefs = null; - this.formatterOptions.remove(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_ENUM_CONSTANT); - this.formatterOptions.remove(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD); - this.formatterOptions.remove(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD); - this.formatterOptions.remove(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE); - this.formatterOptions.remove(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE); - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION, DefaultCodeFormatterConstants.FALSE); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER, JavaCore.DO_NOT_INSERT); - String source = - "@Deprecated package pack;\n" + - "public class Test {\n" + - " @Deprecated Test(String s) {}\n" + - " @Deprecated String label;\n" + - " @Deprecated void foo() {}\n" + - " @Deprecated interface I {}\n" + - "}\n"; - formatSource(source, - "@Deprecated package pack;\n" + - "\n" + - "public class Test {\n" + - " @Deprecated Test(String s) {\n" + - " }\n" + - "\n" + - " @Deprecated String label;\n" + - "\n" + - " @Deprecated void foo() {\n" + - " }\n" + - "\n" + - " @Deprecated interface I {\n" + - " }\n" + - "}\n" - ); -} -public void test729() { - this.formatterPrefs = null; - String profilePath = getResource("profiles", "b308000.xml"); - this.formatterOptions = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(profilePath, "b308000"); - assertNotNull("No preferences", this.formatterOptions); - String source = - "package p;\n" + - "\n" + - "@Deprecated public class C {\n" + - " @Deprecated public static void main(@Deprecated String[] args) {\n" + - " @Deprecated int i= 2;\n" + - " System.out.println(i);\n" + - " }\n" + - "}\n"; - formatSource(source, - "package p;\n" + - "\n" + - "@Deprecated public class C {\n" + - " @Deprecated public static void main(@Deprecated String[] args) {\n" + - " @Deprecated\n" + - " int i = 2;\n" + - " System.out.println(i);\n" + - " }\n" + - "}\n" - ); -} -public void test730() { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - String source = "enum Fail1 {A;;{}}"; - formatSource( - source, - "enum Fail1 {\n" + - " A;\n" + - " ;\n" + - "\n" + - " {\n" + - " }\n" + - "}" - ); -} -public void test731() { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - String source = "enum Fail2 {A,B;;{}}"; - formatSource( - source, - "enum Fail2 {\n" + - " A, B;\n" + - " ;\n" + - "\n" + - " {\n" + - " }\n" + - "}" - ); -} -public void test732() { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - String source = "enum Fail3 {A;;public void foo() {}}"; - formatSource( - source, - "enum Fail3 {\n" + - " A;\n" + - " ;\n" + - "\n" + - " public void foo() {\n" + - " }\n" + - "}" - ); -} -public void test733() { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - String source = "enum Fail4 {A;;public int i = 0;}"; - formatSource( - source, - "enum Fail4 {\n" + - " A;\n" + - " ;\n" + - "\n" + - " public int i = 0;\n" + - "}" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=282988 -public void test734() { - this.formatterPrefs = null; - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_PRESERVE_WHITE_SPACE_BETWEEN_CODE_AND_LINE_COMMENT, DefaultCodeFormatterConstants.TRUE); - String source = - "package p;\n" + - "\n" + - "public class Comment {\n" + - " public static void main(String[] args) {\n" + - " // internal indentation\n" + - " int i = 1; // tabs\n" + - " int j = 2; // spaces\n" + - " int k = 3; // mixed tabs and spaces\n" + - " System.out.print(i); /* does not affect block comments */\n" + - " }\n" + - "}\n"; - formatSource(source, - "package p;\n" + - "\n" + - "public class Comment {\n" + - " public static void main(String[] args) {\n" + - " // internal indentation\n" + - " int i = 1; // tabs\n" + - " int j = 2; // spaces\n" + - " int k = 3; // mixed tabs and spaces\n" + - " System.out.print(i); /* does not affect block comments */\n" + - " }\n" + - "}\n" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=282988 -public void test735() { - this.formatterPrefs = null; - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_PRESERVE_WHITE_SPACE_BETWEEN_CODE_AND_LINE_COMMENT, DefaultCodeFormatterConstants.FALSE); - String source = - "package p;\n" + - "\n" + - "public class Comment {\n" + - " public static void main(String[] args) {\n" + - " // internal indentation\n" + - " int i = 1; // tabs\n" + - " int j = 2; // spaces\n" + - " int k = 3; // mixed tabs and spaces\n" + - " System.out.print(i); /* does not affect block comments */\n" + - " }\n" + - "}\n"; - formatSource(source, - "package p;\n" + - "\n" + - "public class Comment {\n" + - " public static void main(String[] args) {\n" + - " // internal indentation\n" + - " int i = 1; // tabs\n" + - " int j = 2; // spaces\n" + - " int k = 3; // mixed tabs and spaces\n" + - " System.out.print(i); /* does not affect block comments */\n" + - " }\n" + - "}\n" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=282988 -public void test736() { - this.formatterPrefs = null; - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_PRESERVE_WHITE_SPACE_BETWEEN_CODE_AND_LINE_COMMENT, DefaultCodeFormatterConstants.TRUE); - String source = - "package p;\n" + - "\n" + - "public class Comment {\n" + - " public static void main(String[] args) {\n" + - " // internal indentation\n" + - " int i = 1;// tabs\n" + - " int j = 2;// spaces\n" + - " int k = 3;// mixed tabs and spaces\n" + - " System.out.print(i); /* does not affect block comments */\n" + - " }\n" + - "}\n"; - formatSource(source, - "package p;\n" + - "\n" + - "public class Comment {\n" + - " public static void main(String[] args) {\n" + - " // internal indentation\n" + - " int i = 1;// tabs\n" + - " int j = 2;// spaces\n" + - " int k = 3;// mixed tabs and spaces\n" + - " System.out.print(i); /* does not affect block comments */\n" + - " }\n" + - "}\n" - ); -} -//https://bugs.eclipse.org/bugs/show_bug.cgi?id=282988 -public void test737() { - this.formatterPrefs = null; - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_PRESERVE_WHITE_SPACE_BETWEEN_CODE_AND_LINE_COMMENT, DefaultCodeFormatterConstants.FALSE); - String source = - "package p;\n" + - "\n" + - "public class Comment {\n" + - " public static void main(String[] args) {\n" + - " // internal indentation\n" + - " int i = 1;// tabs\n" + - " int j = 2;// spaces\n" + - " int k = 3;// mixed tabs and spaces\n" + - " System.out.print(i); /* does not affect block comments */\n" + - " }\n" + - "}\n"; - formatSource(source, - "package p;\n" + - "\n" + - "public class Comment {\n" + - " public static void main(String[] args) {\n" + - " // internal indentation\n" + - " int i = 1;// tabs\n" + - " int j = 2;// spaces\n" + - " int k = 3;// mixed tabs and spaces\n" + - " System.out.print(i); /* does not affect block comments */\n" + - " }\n" + - "}\n" - ); -} -// binary literals / underscores in literals / multi catch -public void test738() { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - String source = - "public class Test {\n" + - " int i = 0b0001;\n" + - " int j = 0b0_0_0_1;\n" + - " void foo(String s) {\n" + - " try {\n" + - " FileReader reader = new FileReader(s);\n" + - " } catch(FileNotFoundException | IOException | Exception e) {\n" + - " e.printStackTrace();\n" + - " }\n" + - " }\n" + - "}\n"; - formatSource(source, - "public class Test {\n" + - " int i = 0b0001;\n" + - " int j = 0b0_0_0_1;\n" + - "\n" + - " void foo(String s) {\n" + - " try {\n" + - " FileReader reader = new FileReader(s);\n" + - " } catch (FileNotFoundException | IOException | Exception e) {\n" + - " e.printStackTrace();\n" + - " }\n" + - " }\n" + - "}\n" - ); -} -//try-with-resources -public void test739() { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - String source = - "public class Test {\n" + - " void foo(String s) {\n" + - " try (FileReader reader = new FileReader(s)) {\n" + - " reader.read();\n" + - " } catch(IOException e) {\n" + - " e.printStackTrace();\n" + - " }\n" + - " }\n" + - "}\n"; - formatSource(source, - "public class Test {\n" + - " void foo(String s) {\n" + - " try (FileReader reader = new FileReader(s)) {\n" + - " reader.read();\n" + - " } catch (IOException e) {\n" + - " e.printStackTrace();\n" + - " }\n" + - " }\n" + - "}\n" - ); -} -//try-with-resources -public void test740() { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - String source = - "public class Test {\n" + - " void foo(String s) {\n" + - " try (FileReader reader = new FileReader(s)) {\n" + - " reader.read();\n" + - " } catch(IOException e) {\n" + - " e.printStackTrace();\n" + - " }\n" + - " }\n" + - "}\n"; - formatSource(source, - "public class Test {\n" + - " void foo(String s) {\n" + - " try (FileReader reader = new FileReader(s)) {\n" + - " reader.read();\n" + - " } catch (IOException e) {\n" + - " e.printStackTrace();\n" + - " }\n" + - " }\n" + - "}\n" - ); -} -//try-with-resources -public void test741() { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - String source = - "public class Test {\n" + - " void foo(String s) {\n" + - " try (FileReader reader = new FileReader(s)) {\n" + - " reader.read();\n" + - " } catch(IOException e) {\n" + - " e.printStackTrace();\n" + - " } finally {\n" + - " System.out.println(\"finally block\");\n" + - " }\n" + - " }\n" + - "}\n"; - formatSource(source, - "public class Test {\n" + - " void foo(String s) {\n" + - " try (FileReader reader = new FileReader(s)) {\n" + - " reader.read();\n" + - " } catch (IOException e) {\n" + - " e.printStackTrace();\n" + - " } finally {\n" + - " System.out.println(\"finally block\");\n" + - " }\n" + - " }\n" + - "}\n" - ); -} -//try-with-resources -public void test742() { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - String source = - "public class Test {\n" + - " void foo(String s) {\n" + - " try (FileReader reader = new FileReader(s)) {\n" + - " reader.read();\n" + - " } catch(FileNotFoundException | IOException | Exception e) {\n" + - " e.printStackTrace();\n" + - " } finally {\n" + - " System.out.println(\"finally block\");\n" + - " }\n" + - " }\n" + - "}\n"; - formatSource(source, - "public class Test {\n" + - " void foo(String s) {\n" + - " try (FileReader reader = new FileReader(s)) {\n" + - " reader.read();\n" + - " } catch (FileNotFoundException | IOException | Exception e) {\n" + - " e.printStackTrace();\n" + - " } finally {\n" + - " System.out.println(\"finally block\");\n" + - " }\n" + - " }\n" + - "}\n" - ); -} -//try-with-resources -public void test743() { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - String source = - "public class Test {\n" + - " void foo(String s) {\n" + - " try (FileReader reader = new FileReader(s);) {\n" + - " reader.read();\n" + - " } catch(FileNotFoundException | IOException | Exception e) {\n" + - " e.printStackTrace();\n" + - " } finally {\n" + - " System.out.println(\"finally block\");\n" + - " }\n" + - " }\n" + - "}\n"; - formatSource(source, - "public class Test {\n" + - " void foo(String s) {\n" + - " try (FileReader reader = new FileReader(s);) {\n" + - " reader.read();\n" + - " } catch (FileNotFoundException | IOException | Exception e) {\n" + - " e.printStackTrace();\n" + - " } finally {\n" + - " System.out.println(\"finally block\");\n" + - " }\n" + - " }\n" + - "}\n" - ); -} -//try-with-resources -public void test744() { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - setFormatterOptions80(); - String source = - "public class Test {\n" + - " void foo(String s) {\n" + - " try (FileReader reader = new FileReader(s);FileReader reader2 = new FileReader(s)) {\n" + - " reader.read();\n" + - " reader2.read();\n" + - " } catch(FileNotFoundException | IOException | Exception e) {\n" + - " e.printStackTrace();\n" + - " } finally {\n" + - " System.out.println(\"finally block\");\n" + - " }\n" + - " }\n" + - "}\n"; - formatSource(source, - "public class Test {\n" + - " void foo(String s) {\n" + - " try (FileReader reader = new FileReader(s);\n" + - " FileReader reader2 = new FileReader(s)) {\n" + - " reader.read();\n" + - " reader2.read();\n" + - " } catch (FileNotFoundException | IOException | Exception e) {\n" + - " e.printStackTrace();\n" + - " } finally {\n" + - " System.out.println(\"finally block\");\n" + - " }\n" + - " }\n" + - "}\n" - ); -} -//try-with-resources -public void test745() { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - setFormatterOptions80(); - String source = - "public class Test {\n" + - " void foo(String s) {\n" + - " try (FileReader reader = new FileReader(s);FileReader reader2 = new FileReader(s);) {\n" + - " reader.read();\n" + - " reader2.read();\n" + - " } catch(FileNotFoundException | IOException | Exception e) {\n" + - " e.printStackTrace();\n" + - " } finally {\n" + - " System.out.println(\"finally block\");\n" + - " }\n" + - " }\n" + - "}\n"; - formatSource(source, - "public class Test {\n" + - " void foo(String s) {\n" + - " try (FileReader reader = new FileReader(s);\n" + - " FileReader reader2 = new FileReader(s);) {\n" + - " reader.read();\n" + - " reader2.read();\n" + - " } catch (FileNotFoundException | IOException | Exception e) {\n" + - " e.printStackTrace();\n" + - " } finally {\n" + - " System.out.println(\"finally block\");\n" + - " }\n" + - " }\n" + - "}\n" - ); -} -//diamond -public void test746() { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - String source = - "public class Test {\n" + - " List foo(String s) {\n" + - " List l = new ArrayList<>();\n" + - " l.add(s);\n" + - " return l;\n" + - " }\n" + - "}\n"; - formatSource(source, - "public class Test {\n" + - " List foo(String s) {\n" + - " List l = new ArrayList<>();\n" + - " l.add(s);\n" + - " return l;\n" + - " }\n" + - "}\n" - ); -} -//diamond -public void test747() { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - String source = - "public class Test {\n" + - " List foo(String s) {\n" + - " List l = new java.util.ArrayList<>();\n" + - " l.add(s);\n" + - " return l;\n" + - " }\n" + - "}\n"; - formatSource(source, - "public class Test {\n" + - " List foo(String s) {\n" + - " List l = new java.util.ArrayList<>();\n" + - " l.add(s);\n" + - " return l;\n" + - " }\n" + - "}\n" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=335309 -public void test748() { - final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); - DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); - IRegion[] regions = new IRegion[] { - new Region(705, 0) - }; - runTest(codeFormatter, "test748", "RecipeDocumentProvider.java", CodeFormatter.K_COMPILATION_UNIT, 0, true, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349008 -public void test749() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try (FileReader fis = new FileReader(s); FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s)) {\n" + - " }\n" + - " }\n" + - "}\n"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try (FileReader fis = new FileReader(s);\n" + - " FileReader fis2 = new FileReader(s);\n" + - " FileReader fis3 = new FileReader(s)) {\n" + - " }\n" + - " }\n" + - "}\n" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 -// To verify that the whitespace options for resources in try statement work correctly -public void test750() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_TRY, JavaCore.DO_NOT_INSERT); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_TRY, JavaCore.INSERT); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_TRY, JavaCore.INSERT); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_TRY_RESOURCES, JavaCore.INSERT); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try( FileReader fis = new FileReader(s) ;\n" + - " FileReader fis2 = new FileReader(s) ;\n" + - " FileReader fis3 = new FileReader(s) ; ) {\n" + - " }\n" + - " }\n" + - "}\n" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 -// To check behavior with different line wrapping and indentation policies. -public void test751() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NO_SPLIT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - setFormatterOptions80(); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try (FileReader fis = new FileReader(\n" + - " s); FileReader fis2 = new FileReader(\n" + - " s); FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 -// To check behavior with different line wrapping and indentation policies. -public void test752() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try ( FileReader fis = new FileReader(s);\n" + - " FileReader fis2 = new FileReader(s);\n" + - " FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 -// To check behavior with different line wrapping and indentation policies. -public void test753() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_BY_ONE)); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try (FileReader fis = new FileReader(s);\n" + - " FileReader fis2 = new FileReader(s);\n" + - " FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 -// To check behavior with different line wrapping and indentation policies. -public void test754() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "120"); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try (FileReader fis = new FileReader(s); FileReader fis2 = new FileReader(s);\n" + - " FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 -// To check behavior with different line wrapping and indentation policies. -public void test755() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "120"); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try ( FileReader fis = new FileReader(s); FileReader fis2 = new FileReader(s);\n" + - " FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 -// To check behavior with different line wrapping and indentation policies. -public void test756() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_BY_ONE)); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "120"); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try (FileReader fis = new FileReader(s); FileReader fis2 = new FileReader(s);\n" + - " FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 -// To check behavior with different line wrapping and indentation policies. -public void test757() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT_FIRST_BREAK, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "120"); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try (\n" + - " FileReader fis = new FileReader(s); FileReader fis2 = new FileReader(s);\n" + - " FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 -// To check behavior with different line wrapping and indentation policies. -public void test758() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT_FIRST_BREAK, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "120"); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try (\n" + - " FileReader fis = new FileReader(s); FileReader fis2 = new FileReader(s);\n" + - " FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 -// To check behavior with different line wrapping and indentation policies. -public void test759() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT_FIRST_BREAK, DefaultCodeFormatterConstants.INDENT_BY_ONE)); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "120"); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try (\n" + - " FileReader fis = new FileReader(s); FileReader fis2 = new FileReader(s);\n" + - " FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 -// To check behavior with different line wrapping and indentation policies. -public void test760() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_SHIFTED, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "120"); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try (\n" + - " FileReader fis = new FileReader(s);\n" + - " FileReader fis2 = new FileReader(s);\n" + - " FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 -// To check behavior with different line wrapping and indentation policies. -public void test761() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_SHIFTED, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "120"); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try (\n" + - " FileReader fis = new FileReader(s);\n" + - " FileReader fis2 = new FileReader(s);\n" + - " FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 -// To check behavior with different line wrapping and indentation policies. -public void test762() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_SHIFTED, DefaultCodeFormatterConstants.INDENT_BY_ONE)); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "120"); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try (\n" + - " FileReader fis = new FileReader(s);\n" + - " FileReader fis2 = new FileReader(s);\n" + - " FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 -// To check behavior with different line wrapping and indentation policies. -public void test763() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "120"); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try (\n" + - " FileReader fis = new FileReader(s);\n" + - " FileReader fis2 = new FileReader(s);\n" + - " FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 -// To check behavior with different line wrapping and indentation policies. -public void test764() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_BY_ONE)); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "120"); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try (\n" + - " FileReader fis = new FileReader(s);\n" + - " FileReader fis2 = new FileReader(s);\n" + - " FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 -// To check behavior with different line wrapping and indentation policies. -public void test765() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "120"); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void storeSomething(String s) throws Exception {\n" + - " try (\n" + - " FileReader fis = new FileReader(s);\n" + - " FileReader fis2 = new FileReader(s);\n" + - " FileReader fis3 = new FileReader(s);) {\n" + - " }\n" + - " }\n" + - "}\n" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 -// To check behavior with different line wrapping and indentation policies. -public void test766() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NO_SPLIT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try{\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "class MyE extends Exception {}"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try {\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE | FileNotFoundException | ArrayIndexOutOfBoundsException | IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "\n" + - "class MyE extends Exception {\n" + - "}" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 -// To check behavior with default settings. -public void test767() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - setFormatterOptions80(); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try{\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "class MyE extends Exception {}"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try {\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE | FileNotFoundException | ArrayIndexOutOfBoundsException\n" + - " | IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "\n" + - "class MyE extends Exception {\n" + - "}" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 -// To check behavior with default settings. -public void test767a() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "60"); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try{\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "class MyE extends Exception {}"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try {\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE | FileNotFoundException\n" + - " | ArrayIndexOutOfBoundsException\n" + - " | IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "\n" + - "class MyE extends Exception {\n" + - "}" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 -// To check behavior with default settings, and spaces before '|' and not after them. -public void test767b() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BITWISE_OPERATOR, JavaCore.INSERT); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_BITWISE_OPERATOR, JavaCore.DO_NOT_INSERT); - setFormatterOptions80(); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try{\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "class MyE extends Exception {}"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try {\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE |FileNotFoundException |ArrayIndexOutOfBoundsException\n" + - " |IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "\n" + - "class MyE extends Exception {\n" + - "}" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 -// To check behavior with different line wrapping and indentation policies. -public void test768() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - setFormatterOptions80(); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try{\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "class MyE extends Exception {}"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try {\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch ( MyE | FileNotFoundException | ArrayIndexOutOfBoundsException\n" + - " | IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "\n" + - "class MyE extends Exception {\n" + - "}" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 -// To check behavior with different line wrapping and indentation policies. -public void test769() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_BY_ONE)); - setFormatterOptions80(); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try{\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "class MyE extends Exception {}"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try {\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE | FileNotFoundException | ArrayIndexOutOfBoundsException\n" + - " | IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "\n" + - "class MyE extends Exception {\n" + - "}" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 -// To check behavior with different line wrapping and indentation policies. -public void test770() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT_FIRST_BREAK, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - setFormatterOptions80(); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try{\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "class MyE extends Exception {}"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try {\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (\n" + - " MyE | FileNotFoundException | ArrayIndexOutOfBoundsException\n" + - " | IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "\n" + - "class MyE extends Exception {\n" + - "}" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 -// To check behavior with different line wrapping and indentation policies. -public void test771() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT_FIRST_BREAK, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - setFormatterOptions80(); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try{\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "class MyE extends Exception {}"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try {\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (\n" + - " MyE | FileNotFoundException | ArrayIndexOutOfBoundsException\n" + - " | IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "\n" + - "class MyE extends Exception {\n" + - "}" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 -// To check behavior with different line wrapping and indentation policies. -public void test772() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT_FIRST_BREAK, DefaultCodeFormatterConstants.INDENT_BY_ONE)); - setFormatterOptions80(); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try{\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "class MyE extends Exception {}"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try {\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (\n" + - " MyE | FileNotFoundException | ArrayIndexOutOfBoundsException\n" + - " | IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "\n" + - "class MyE extends Exception {\n" + - "}" - ); -} - -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 -// To check behavior with different line wrapping and indentation policies. -public void test773() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - setFormatterOptions80(); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try{\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "class MyE extends Exception {}"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try {\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE\n" + - " | FileNotFoundException\n" + - " | ArrayIndexOutOfBoundsException\n" + - " | IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "\n" + - "class MyE extends Exception {\n" + - "}" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 -// To check behavior with different line wrapping and indentation policies. -public void test774() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - setFormatterOptions80(); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try{\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "class MyE extends Exception {}"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try {\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch ( MyE\n" + - " | FileNotFoundException\n" + - " | ArrayIndexOutOfBoundsException\n" + - " | IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "\n" + - "class MyE extends Exception {\n" + - "}" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 -// To check behavior with different line wrapping and indentation policies. -public void test775() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_BY_ONE)); - setFormatterOptions80(); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try{\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "class MyE extends Exception {}"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try {\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE\n" + - " | FileNotFoundException\n" + - " | ArrayIndexOutOfBoundsException\n" + - " | IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "\n" + - "class MyE extends Exception {\n" + - "}" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 -// To check behavior with different line wrapping and indentation policies. -public void test776() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_SHIFTED, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - setFormatterOptions80(); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try{\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "class MyE extends Exception {}"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try {\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (\n" + - " MyE\n" + - " | FileNotFoundException\n" + - " | ArrayIndexOutOfBoundsException\n" + - " | IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "\n" + - "class MyE extends Exception {\n" + - "}" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 -// To check behavior with different line wrapping and indentation policies. -public void test777() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_SHIFTED, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - setFormatterOptions80(); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try{\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "class MyE extends Exception {}"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try {\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (\n" + - " MyE\n" + - " | FileNotFoundException\n" + - " | ArrayIndexOutOfBoundsException\n" + - " | IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "\n" + - "class MyE extends Exception {\n" + - "}" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 -// To check behavior with different line wrapping and indentation policies. -public void test778() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_SHIFTED, DefaultCodeFormatterConstants.INDENT_BY_ONE)); - setFormatterOptions80(); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try{\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "class MyE extends Exception {}"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try {\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (\n" + - " MyE\n" + - " | FileNotFoundException\n" + - " | ArrayIndexOutOfBoundsException\n" + - " | IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "\n" + - "class MyE extends Exception {\n" + - "}" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 -// To check behavior with different line wrapping and indentation policies. -public void test779() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - setFormatterOptions80(); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try{\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "class MyE extends Exception {}"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try {\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (\n" + - " MyE\n" + - " | FileNotFoundException\n" + - " | ArrayIndexOutOfBoundsException\n" + - " | IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "\n" + - "class MyE extends Exception {\n" + - "}" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 -// To check behavior with different line wrapping and indentation policies. -public void test780() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); - setFormatterOptions80(); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try{\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "class MyE extends Exception {}"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try {\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (\n" + - " MyE\n" + - " | FileNotFoundException\n" + - " | ArrayIndexOutOfBoundsException\n" + - " | IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "\n" + - "class MyE extends Exception {\n" + - "}" - ); -} -//https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 -//To check behavior with different line wrapping and indentation policies. -public void test781() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_BY_ONE)); - setFormatterOptions80(); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try{\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "class MyE extends Exception {}"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try {\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (\n" + - " MyE\n" + - " | FileNotFoundException\n" + - " | ArrayIndexOutOfBoundsException\n" + - " | IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "\n" + - "class MyE extends Exception {\n" + - "}" - ); -} -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=350895 -// To check behavior with default settings and wrap before '|' operator disabled. -public void test782() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_WRAP_BEFORE_OR_OPERATOR_MULTICATCH, JavaCore.DISABLED); - setFormatterOptions80(); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try{\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "class MyE extends Exception {}"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " public void foo(boolean a) {\n" + - " try {\n" + - " if (a)\n" + - " throw new FileNotFoundException();\n" + - " else\n" + - " throw new MyE();\n" + - " } catch (MyE | FileNotFoundException | ArrayIndexOutOfBoundsException |\n" + - " IllegalArgumentException ex) {\n" + - " }\n" + - " }\n" + - "}\n" + - "\n" + - "class MyE extends Exception {\n" + - "}" - ); -} -//https://bugs.eclipse.org/bugs/show_bug.cgi?id=359646 -public void test783() throws Exception { - this.formatterPrefs = null; - String source = - "public class X {public static void main(String[] args) {\n" + - " long x = 0x8000000000000000L;\n" + - " System.out.println(x);\n" + - " }\n" + - "}"; - formatSource(source, - "public class X {\n" + - " public static void main(String[] args) {\n" + - " long x = 0x8000000000000000L;\n" + - " System.out.println(x);\n" + - " }\n" + - "}" - ); -} - -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=379793 -// To verify that the whitespace options for resources in try statement work correctly -public void testBug379793() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "80"); - this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_TRY, JavaCore.INSERT); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_TRY_RESOURCES, JavaCore.INSERT); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION, "1"); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "2"); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, "2"); - this.formatterOptions.put( - DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, - DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); - String source = - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " void jbtnJDBCTest_actionPerformed(final ActionEvent e) {\n" + - " if ((driverClasses != null) && (JDBCURL != null)) {\n" + - " if (test == true) {\n" + - " try (final Connection connection = DriverManager.getConnection(JDBCURL);) {\n" + - " test = (connection != null);\n" + - " if (test == true) {\n" + - " jTextArea1.setText(\"The test was completeted successfully!\");\n" + - " }\n" + - " } catch (final SQLException sx) {\n" + - " jTextArea1\n" + - " .setText(\"\");\n" + - " }\n" + - " }\n" + - " }\n" + - " }\n" + - "}\n"; - formatSource(source, - "package test;\n" + - "\n" + - "public class FormatterError {\n" + - " void jbtnJDBCTest_actionPerformed(final ActionEvent e) {\n" + - " if ((driverClasses != null) && (JDBCURL != null)) {\n" + - " if (test == true) {\n" + - " try (\n" + - " final Connection connection = DriverManager.getConnection(JDBCURL);) {\n" + - " test = (connection != null);\n" + - " if (test == true) {\n" + - " jTextArea1.setText(\"The test was completeted successfully!\");\n" + - " }\n" + - " } catch (final SQLException sx) {\n" + - " jTextArea1.setText(\"\");\n" + - " }\n" + - " }\n" + - " }\n" + - " }\n" + - "}\n" - ); -} -//https://bugs.eclipse.org/bugs/show_bug.cgi?id=405038 -//To verify that the whitespace options for resources in try statement work correctly -public void testBug405038() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ADDITIVE_OPERATOR, JavaCore.DO_NOT_INSERT); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ADDITIVE_OPERATOR, JavaCore.DO_NOT_INSERT); - String source = - "public class FormatterError {\n" + - " int foo(int a, int b, int c) {\n" + - " return a + b + ++c;\n" + - " }\n" + - "}\n"; - formatSource(source, - "public class FormatterError {\n" + - " int foo(int a, int b, int c) {\n" + - " return a+b+ ++c;\n" + - " }\n" + - "}\n" - ); -} -//https://bugs.eclipse.org/bugs/show_bug.cgi?id=405038 -//To verify that the whitespace options for resources in try statement work correctly -public void testBug405038_2() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ADDITIVE_OPERATOR, JavaCore.DO_NOT_INSERT); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ADDITIVE_OPERATOR, JavaCore.DO_NOT_INSERT); - String source = - "public class FormatterError {\n" + - " int foo(int a, int b, int c) {\n" + - " return a + ++b + c;\n" + - " }\n" + - "}\n"; - formatSource(source, - "public class FormatterError {\n" + - " int foo(int a, int b, int c) {\n" + - " return a+ ++b+c;\n" + - " }\n" + - "}\n" - ); -} -//https://bugs.eclipse.org/bugs/show_bug.cgi?id=405038 -//To verify that the whitespace options for resources in try statement work correctly -public void testBug405038_3() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ADDITIVE_OPERATOR, JavaCore.DO_NOT_INSERT); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ADDITIVE_OPERATOR, JavaCore.DO_NOT_INSERT); - String source = - "public class FormatterError {\n" + - " int foo(int a, int b, int c) {\n" + - " return a - --b + c;\n" + - " }\n" + - "}\n"; - formatSource(source, - "public class FormatterError {\n" + - " int foo(int a, int b, int c) {\n" + - " return a- --b+c;\n" + - " }\n" + - "}\n" - ); -} -//https://bugs.eclipse.org/bugs/show_bug.cgi?id=405038 -//To verify that the whitespace options for resources in try statement work correctly -public void testBug405038_4() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ADDITIVE_OPERATOR, JavaCore.DO_NOT_INSERT); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ADDITIVE_OPERATOR, JavaCore.DO_NOT_INSERT); - String source = - "public class FormatterError {\n" + - " int foo(int a, int b, int c) {\n" + - " return a - -b + c;\n" + - " }\n" + - "}\n"; - formatSource(source, - "public class FormatterError {\n" + - " int foo(int a, int b, int c) {\n" + - " return a- -b+c;\n" + - " }\n" + - "}\n" - ); -} -//https://bugs.eclipse.org/bugs/show_bug.cgi?id=405038 -//To verify that the whitespace options for resources in try statement work correctly -public void testBug405038_5() throws Exception { - this.formatterPrefs = null; - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ADDITIVE_OPERATOR, JavaCore.DO_NOT_INSERT); - this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ADDITIVE_OPERATOR, JavaCore.DO_NOT_INSERT); - String source = - "public class FormatterError {\n" + - " int foo(int a, int b, int c) {\n" + - " return a - -b + ++c;\n" + - " }\n" + - "}\n"; - formatSource(source, - "public class FormatterError {\n" + - " int foo(int a, int b, int c) {\n" + - " return a- -b+ ++c;\n" + - " }\n" + - "}\n" - ); -} - -//https://bugs.eclipse.org/bugs/show_bug.cgi?id=432593 -public void testBug432593() throws IOException { - ICompilationUnit sourceUnit; - try { - sourceUnit = getCompilationUnit("Formatter" , "", "test432593", getIn("A.java")); - String src = sourceUnit.getSource(); - assertNotNull(src); - String source = src.toString(); - final Map options = JavaCore.getOptions(); - options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); - options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); - options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); - final CodeFormatter codeFormatter = ToolFactory.createCodeFormatter(options); - final TextEdit edit = codeFormatter.format(CodeFormatter.K_COMPILATION_UNIT, source, 0, source.length(), 0, "\r\n"); - assertTrue(edit != null); - } catch (JavaModelException e) { - e.printStackTrace(); - } -} -//https://bugs.eclipse.org/bugs/show_bug.cgi?id=467229 -public void testBug467229() throws IOException { - final Map optionsMap = JavaCore.getOptions(); - int tabSize = 3; - int indentSize = 5; - String[] keysToCheck = { - DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, - DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE }; - - optionsMap.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, tabSize + ""); - optionsMap.put(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, indentSize + ""); - - /* compare with org.eclipse.jdt.internal.ui.preferences.formatter.IndentationTabPage.updateTabPreferences() */ - optionsMap.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, DefaultCodeFormatterConstants.MIXED); - DefaultCodeFormatterOptions options = new DefaultCodeFormatterOptions(optionsMap); - assertEquals(tabSize, options.tab_size); - assertEquals(indentSize, options.indentation_size); - Map optionsMap2 = options.getMap(); - for (String key : keysToCheck) { - assertEquals(key, optionsMap.get(key), optionsMap2.get(key)); - } - - optionsMap.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); - options.set(optionsMap); - assertEquals(indentSize, options.tab_size); - assertEquals(tabSize, options.indentation_size); - optionsMap2 = options.getMap(); - for (String key : keysToCheck) { - assertEquals(key, optionsMap.get(key), optionsMap2.get(key)); - } - - optionsMap.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); - options.set(optionsMap); - assertEquals(tabSize, options.tab_size); - assertEquals(tabSize, options.indentation_size); - optionsMap2 = options.getMap(); - String key = keysToCheck[0]; // the other is lost in this conversion - assertEquals(key, optionsMap.get(key), optionsMap2.get(key)); -} -/** - * https://bugs.eclipse.org/477476 - Auto-formatter gets indentation wrong when used as post-save action - */ -public void testBug477476a() { - setComplianceLevel(CompilerOptions.VERSION_1_5); - this.formatterPrefs.use_tabs_only_for_leading_indentations = true; - runTest(codeFormatter(), "test477476a", "A.java", CodeFormatter.K_COMPILATION_UNIT, false); -} -/** - * https://bugs.eclipse.org/477476 - Auto-formatter gets indentation wrong when used as post-save action - */ -public void testBug477476b() { - setComplianceLevel(CompilerOptions.VERSION_1_5); - try { - String input = getCompilationUnit("Formatter" , "", "test477476b", "A_in.java").getSource(); - String output = getCompilationUnit("Formatter" , "", "test477476b", "A_out.java").getSource(); - formatSource(input, output); - } catch (JavaModelException e) { - e.printStackTrace(); - assertTrue(false); - } -} -/** - * https://bugs.eclipse.org/485495 - [Formatter] does not insert space before semicolon at the end of the statement - */ -public void testBug485495() { - this.formatterPrefs.insert_space_before_semicolon = true; - String source = - "package test ;\n" + - "\n" + - "import java.util.ArrayList ;\n" + - "\n" + - "public class Test {\n" + - "\n" + - " interface I {\n" + - " void method() ;\n" + - " }\n" + - "\n" + - " ArrayList e = null ;\n" + - " int i ;\n" + - "\n" + - " void foo() {\n" + - " int i = 0 ;\n" + - " String s ;\n" + - " if (i > 0)\n" + - " return ;\n" + - " for (int j = 0; j < 5; j++) {\n" + - " Object o ;\n" + - " while (i < 0)\n" + - " o = new Object() {\n" + - " int f ;\n" + - "\n" + - " void bar() {\n" + - " if (f > 0)\n" + - " f = 5 ;\n" + - " else\n" + - " f = 16 ;\n" + - " try {\n" + - " f = 14 ;\n" + - " } catch (Exception e) {\n" + - " bar() ;\n" + - " }\n" + - " }\n" + - " } ;\n" + - " while (i < 0)\n" + - " switch (i) {\n" + - " case 4:\n" + - " foo() ;\n" + - " }\n" + - " }\n" + - " }\n" + - "}"; - formatSource(source); -} -/** - * https://bugs.eclipse.org/479109 - [formatter] Add option to group aligned fields with blank lines - */ -public void testBug479109a() { - this.formatterPrefs.align_type_members_on_columns = true; - this.formatterPrefs.align_fields_grouping_blank_lines = 1; - String source = - "public class Test {\n" + - " String field1 = \"1\"; //\n" + - "\n" + - " public String field2 = \"2222\"; //\n" + - "\n" + - "\n" + - " protected final String field3 = \"333333333\"; //\n" + - "}"; - formatSource(source, - "public class Test {\n" + - " String field1 = \"1\"; //\n" + - "\n" + - " public String field2 = \"2222\"; //\n" + - "\n" + - " protected final String field3 = \"333333333\"; //\n" + - "}" - ); -} -/** - * https://bugs.eclipse.org/479109 - [formatter] Add option to group aligned fields with blank lines - */ -public void testBug479109b() { - this.formatterPrefs.align_type_members_on_columns = true; - this.formatterPrefs.align_fields_grouping_blank_lines = 2; - String source = - "public class Test {\n" + - " String field1 = \"1\";\n" + - "\n" + - " public String field2222 = \"2222\";\n" + - "\n" + - "\n" + - " protected final String field3 = \"333333333\";\n" + - "}"; - formatSource(source, - "public class Test {\n" + - " String field1 = \"1\";\n" + - "\n" + - " public String field2222 = \"2222\";\n" + - "\n" + - " protected final String field3 = \"333333333\";\n" + - "}" - ); -} -/** - * https://bugs.eclipse.org/479109 - [formatter] Add option to group aligned fields with blank lines - */ -public void testBug479109c() { - this.formatterPrefs.align_type_members_on_columns = true; - this.formatterPrefs.align_fields_grouping_blank_lines = 2; - this.formatterPrefs.number_of_empty_lines_to_preserve = 2; - String source = - "public class Test {\n" + - " String field1 = \"1\"; //\n" + - "\n" + - " public String field2222 = \"2222\"; //\n" + - "\n" + - "\n" + - " protected final String field3 = \"333333333\"; //\n" + - "}"; - formatSource(source, - "public class Test {\n" + - " String field1 = \"1\"; //\n" + - "\n" + - " public String field2222 = \"2222\"; //\n" + - "\n" + - "\n" + - " protected final String field3 = \"333333333\"; //\n" + - "}" - ); -} -/** - * https://bugs.eclipse.org/479109 - [formatter] Add option to group aligned fields with blank lines - */ -public void testBug479109d() { - setFormatLineCommentOnFirstColumn(); - this.formatterPrefs.align_type_members_on_columns = true; - this.formatterPrefs.align_fields_grouping_blank_lines = 2; - String source = - "public class Test {\n" + - " String field1 = \"1\";\n" + - "\n" + - " public String field2222 = \"2222\";\n" + - "\n" + - "// group separator\n" + - "\n" + - " protected final String field3 = \"333333333\";\n" + - "}"; - formatSource(source, - "public class Test {\n" + - " String field1 = \"1\";\n" + - "\n" + - " public String field2222 = \"2222\";\n" + - "\n" + - " // group separator\n" + - "\n" + - " protected final String field3 = \"333333333\";\n" + - "}" - ); -} -/** - * https://bugs.eclipse.org/487375 - [formatter] block comment in front of method signature effects too much indentation - */ -public void testBug486719() { - this.formatterPrefs.page_width = 80; - String source = - "public class Example {\n" + - " int foo(Object a, Object b, Object c) {\n" + - " if (a == b) return 1;if (a == c) return 2; //$IDENTITY-COMPARISON$\n" + - " boolean aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a == b && a == c; //$IDENTITY-COMPARISON$\n" + - " return 3;\n" + - " }\n" + - "}"; - formatSource(source); -} -/** - * https://bugs.eclipse.org/432628 - [formatter] Add option "Insert new line after annotations on enum constants" - */ -public void testBug432628a() { - setComplianceLevel(CompilerOptions.VERSION_1_5); - this.formatterPrefs.insert_new_line_after_annotation_on_enum_constant = false; - String source = - "public enum SomeEnum {\n" + - " @XmlEnumValue(\"val1\") VAL_1(\"val1\"), @XmlEnumValue(\"val2\") VAL_2(\"val2\");\n" + - "}"; - formatSource(source); -} -/** - * https://bugs.eclipse.org/432628 - [formatter] Add option "Insert new line after annotations on enum constants" - */ -public void testBug432628b() { - setComplianceLevel(CompilerOptions.VERSION_1_5); - this.formatterPrefs.insert_new_line_after_annotation_on_enum_constant = true; - String source = - "public enum SomeEnum {\n" + - " @XmlEnumValue(\"val1\")\n" + - " VAL_1(\"val1\"), @XmlEnumValue(\"val2\")\n" + - " VAL_2(\"val2\");\n" + - "}"; - formatSource(source); -} -/** - * https://bugs.eclipse.org/432628 - [formatter] Add option "Insert new line after annotations on enum constants" - */ -public void testBug432628c() { - setComplianceLevel(CompilerOptions.VERSION_1_5); - this.formatterPrefs.insert_new_line_after_annotation_on_enum_constant = true; - this.formatterPrefs.alignment_for_enum_constants = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; - String source = - "public enum SomeEnum {\n" + - " @XmlEnumValue(\"val1\")\n" + - " VAL_1(\"val1\"),\n" + - " @XmlEnumValue(\"val2\")\n" + - " VAL_2(\"val2\");\n" + - "}"; - formatSource(source); -} -/** - * https://bugs.eclipse.org/432628 - [formatter] Add option "Insert new line after annotations on enum constants" - */ -public void testBug432628d() { - setComplianceLevel(CompilerOptions.VERSION_1_5); - this.formatterPrefs.insert_new_line_after_annotation_on_enum_constant = false; - this.formatterPrefs.alignment_for_enum_constants = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; - String source = - "public enum SomeEnum {\n" + - " @XmlEnumValue(\"val1\") VAL_1(\"val1\"),\n" + - " @XmlEnumValue(\"val2\") VAL_2(\"val2\");\n" + - "}"; - formatSource(source); -} -/** - * https://bugs.eclipse.org/118264 - [formatter] Enable wrapping of for loop setup - */ -public void testBug118264a() { - this.formatterPrefs.page_width = 50; - String source = - "class Example {\n" + - " int foo(int argument) {\n" + - " for (int counter = 0; counter < argument; counter++) {\n" + - " doSomething(counter);\n" + - " }\n" + - " }\n" + - "}"; - formatSource(source); -} -/** - * https://bugs.eclipse.org/118264 - [formatter] Enable wrapping of for loop setup - */ -public void testBug118264b() { - this.formatterPrefs.alignment_for_expressions_in_for_loop_header = Alignment.M_COMPACT_SPLIT; - this.formatterPrefs.page_width = 50; - String source = - "class Example {\n" + - " int foo(int argument) {\n" + - " for (int counter = 0; counter < argument; counter++) {\n" + - " doSomething(counter);\n" + - " }\n" + - " }\n" + - "}"; - formatSource(source, - "class Example {\n" + - " int foo(int argument) {\n" + - " for (int counter = 0; counter < argument;\n" + - " counter++) {\n" + - " doSomething(counter);\n" + - " }\n" + - " }\n" + - "}" - ); -} -/** - * https://bugs.eclipse.org/118264 - [formatter] Enable wrapping of for loop setup - */ -public void testBug118264c() { - this.formatterPrefs.alignment_for_expressions_in_for_loop_header = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; - String source = - "class Example {\n" + - " int foo(int argument) {\n" + - " for (int counter = 0; counter < argument; counter++) {\n" + - " doSomething(counter);\n" + - " }\n" + - " }\n" + - "}"; - formatSource(source, - "class Example {\n" + - " int foo(int argument) {\n" + - " for (\n" + - " int counter = 0;\n" + - " counter < argument;\n" + - " counter++) {\n" + - " doSomething(counter);\n" + - " }\n" + - " }\n" + - "}" - ); -} -/** - * https://bugs.eclipse.org/118264 - [formatter] Enable wrapping of for loop setup - */ -public void testBug118264d() { - this.formatterPrefs.alignment_for_expressions_in_for_loop_header = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; - String source = - "class Example {\n" + - " int foo(int argument) {\n" + - " for (int counter = 0; ; ) {\n" + - " doSomething(counter);\n" + - " }\n" + - " }\n" + - "}"; - formatSource(source, - "class Example {\n" + - " int foo(int argument) {\n" + - " for (\n" + - " int counter = 0;;) {\n" + - " doSomething(counter);\n" + - " }\n" + - " }\n" + - "}" - ); -} -/** - * https://bugs.eclipse.org/118264 - [formatter] Enable wrapping of for loop setup - */ -public void testBug118264e() { - this.formatterPrefs.alignment_for_expressions_in_for_loop_header = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; - String source = - "class Example {\n" + - " int foo(int argument) {\n" + - " for (;;argument--, argument--) {\n" + - " doSomething(counter);\n" + - " }\n" + - " }\n" + - "}"; - formatSource(source, - "class Example {\n" + - " int foo(int argument) {\n" + - " for (;;\n" + - " argument--, argument--) {\n" + - " doSomething(counter);\n" + - " }\n" + - " }\n" + - "}" - ); -} -/** - * https://bugs.eclipse.org/118264 - [formatter] Enable wrapping of for loop setup - */ -public void testBug118264f() { - this.formatterPrefs.alignment_for_expressions_in_for_loop_header = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; - String source = - "class Example {\n" + - " int foo(int argument) {\n" + - " for (;;) {\n" + - " doSomething(counter);\n" + - " }\n" + - " }\n" + - "}"; - formatSource(source); -} -/** - * https://bugs.eclipse.org/465910 - [formatter] add a 'wrap before operator' option for conditional expressions - */ -public void testBug465910() { - this.formatterPrefs.alignment_for_conditional_expression = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; - String source = - "class Example {\n" + - " Result foo(boolean argument) {\n" + - " return argument ? doOneThing() : doOtherThing();\n" + - " }\n" + - "}"; - formatSource(source, - "class Example {\n" + - " Result foo(boolean argument) {\n" + - " return argument\n" + - " ? doOneThing()\n" + - " : doOtherThing();\n" + - " }\n" + - "}" - ); - this.formatterPrefs.wrap_before_conditional_operator = false; - formatSource(source, - "class Example {\n" + - " Result foo(boolean argument) {\n" + - " return argument ?\n" + - " doOneThing() :\n" + - " doOtherThing();\n" + - " }\n" + - "}" - ); -} -/** - * https://bugs.eclipse.org/325631 - [formatter] Code formatter Expressions > Assignments lacks "Wrap before operator" option - */ -public void testBug325631() { - this.formatterPrefs.alignment_for_assignment = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; - String source = - "class Example {\n" + - " String value = \"\";\n" + - " void foo(boolean argument) {\n" + - " if (\"test\".equals(value = artument))\n" + - " doSomething();\n" + - " }\n" + - "}"; - formatSource(source, - "class Example {\n" + - " String value =\n" + - " \"\";\n" + - "\n" + - " void foo(boolean argument) {\n" + - " if (\"test\".equals(value =\n" + - " artument))\n" + - " doSomething();\n" + - " }\n" + - "}"); - this.formatterPrefs.wrap_before_assignment_operator = true; - formatSource(source, - "class Example {\n" + - " String value\n" + - " = \"\";\n" + - "\n" + - " void foo(boolean argument) {\n" + - " if (\"test\".equals(value\n" + - " = artument))\n" + - " doSomething();\n" + - " }\n" + - "}" - ); -} -/** - * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions - */ -public void testBug370540a() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out01.java").getSource()); -} -/** - * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions - */ -public void testBug370540b() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.parenthesis_positions_in_method_declaration = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_NOT_EMPTY; - String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out02.java").getSource()); -} -/** - * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions - */ -public void testBug370540c() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.parenthesis_positions_in_method_declaration = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_WRAPPED; - String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out03.java").getSource()); -} -/** - * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions - */ -public void testBug370540d() throws JavaModelException { - this.formatterPrefs.parenthesis_positions_in_method_declaration = DefaultCodeFormatterConstants.SEPARATE_LINES; - setComplianceLevel(CompilerOptions.VERSION_1_8); - String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out04.java").getSource()); -} -/** - * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions - */ -public void testBug370540e() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.parenthesis_positions_in_method_invocation = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_NOT_EMPTY; - String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out05.java").getSource()); -} -/** - * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions - */ -public void testBug370540f() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.parenthesis_positions_in_method_invocation = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_WRAPPED; - this.formatterPrefs.parenthesis_positions_in_enum_constant_declaration = DefaultCodeFormatterConstants.SEPARATE_LINES; - String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out06.java").getSource()); -} -/** - * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions - */ -public void testBug370540g() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.parenthesis_positions_in_enum_constant_declaration = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_NOT_EMPTY; - this.formatterPrefs.parenthesis_positions_in_if_while_statement = DefaultCodeFormatterConstants.SEPARATE_LINES; - String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out07.java").getSource()); -} -/** - * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions - */ -public void testBug370540h() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.parenthesis_positions_in_if_while_statement = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_WRAPPED; - this.formatterPrefs.parenthesis_positions_in_lambda_declaration = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_NOT_EMPTY; - String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out08.java").getSource()); -} -/** - * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions - */ -public void testBug370540i() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.parenthesis_positions_in_if_while_statement = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_WRAPPED; - this.formatterPrefs.parenthesis_positions_in_method_invocation = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_NOT_EMPTY; - String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out09.java").getSource()); -} -/** - * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions - */ -public void testBug370540j() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.parenthesis_positions_in_try_clause = DefaultCodeFormatterConstants.SEPARATE_LINES; - this.formatterPrefs.parenthesis_positions_in_method_declaration = DefaultCodeFormatterConstants.PRESERVE_POSITIONS; - String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out10.java").getSource()); -} -/** - * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions - */ -public void testBug370540k() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.parenthesis_positions_in_catch_clause = DefaultCodeFormatterConstants.SEPARATE_LINES; - this.formatterPrefs.parenthesis_positions_in_if_while_statement = DefaultCodeFormatterConstants.PRESERVE_POSITIONS; - String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out11.java").getSource()); -} -/** - * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions - */ -public void testBug370540l() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.parenthesis_positions_in_for_statement = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_WRAPPED; - this.formatterPrefs.parenthesis_positions_in_annotation = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_NOT_EMPTY; - String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out12.java").getSource()); -} -/** - * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions - */ -public void testBug370540m() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.parenthesis_positions_in_for_statement = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_WRAPPED; - this.formatterPrefs.alignment_for_expressions_in_for_loop_header = Alignment.M_NEXT_PER_LINE_SPLIT + Alignment.M_FORCE; - String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out13.java").getSource()); -} -/** - * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions - */ -public void testBug370540n() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.parenthesis_positions_in_switch_statement = DefaultCodeFormatterConstants.SEPARATE_LINES; - this.formatterPrefs.parenthesis_positions_in_annotation = DefaultCodeFormatterConstants.SEPARATE_LINES; - String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out14.java").getSource()); -} -/** - * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions - */ -public void testBug370540p() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.parenthesis_positions_in_annotation = DefaultCodeFormatterConstants.SEPARATE_LINES; - this.formatterPrefs.parenthesis_positions_in_catch_clause = DefaultCodeFormatterConstants.SEPARATE_LINES; - this.formatterPrefs.parenthesis_positions_in_enum_constant_declaration = DefaultCodeFormatterConstants.SEPARATE_LINES; - this.formatterPrefs.parenthesis_positions_in_for_statement = DefaultCodeFormatterConstants.SEPARATE_LINES; - this.formatterPrefs.parenthesis_positions_in_if_while_statement = DefaultCodeFormatterConstants.SEPARATE_LINES; - this.formatterPrefs.parenthesis_positions_in_lambda_declaration = DefaultCodeFormatterConstants.SEPARATE_LINES; - this.formatterPrefs.parenthesis_positions_in_method_declaration = DefaultCodeFormatterConstants.SEPARATE_LINES; - this.formatterPrefs.parenthesis_positions_in_method_invocation = DefaultCodeFormatterConstants.SEPARATE_LINES; - this.formatterPrefs.parenthesis_positions_in_switch_statement = DefaultCodeFormatterConstants.SEPARATE_LINES; - this.formatterPrefs.parenthesis_positions_in_try_clause = DefaultCodeFormatterConstants.SEPARATE_LINES; - String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out15.java").getSource()); -} -/** - * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions - */ -public void testBug370540q() throws JavaModelException { - this.formatterPrefs.parenthesis_positions_in_for_statement = DefaultCodeFormatterConstants.SEPARATE_LINES; - String source = - "public class Test {\n" + - " void foo() {\n" + - " for (\n" + - " String s : Arrays.asList(\"aa\")\n" + - " ) {\n" + - " }\n" + - " }\n" + - "}"; - formatSource(source); -} -/** - * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions - */ -public void testBug370540r() throws JavaModelException { - this.formatterPrefs.parenthesis_positions_in_method_invocation = DefaultCodeFormatterConstants.SEPARATE_LINES; - String source = - "public class Test extends Exception {\n" + - " Test instance = new Test(\n" + - " 1\n" + - " );\n" + - "\n" + - " Test(int a) {\n" + - " this(\n" + - " a, 0\n" + - " );\n" + - " }\n" + - "\n" + - " Test(int a, int b) {\n" + - " super(\n" + - " a + \"=\" + b\n" + - " );\n" + - " }\n" + - "\n" + - " public void printStackTrace() {\n" + - " super.printStackTrace(\n" + - " );\n" + - " }\n" + - "}"; - formatSource(source); -} -/** - * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions - */ -public void testBug370540s() throws JavaModelException { - this.formatterPrefs.parenthesis_positions_in_method_invocation = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_WRAPPED; - String source = - "public class Test extends Exception {\n" + - " void foo() {\n" + - " new StringBuilder().append(\"aaaaaaaaa\" + \"bbbbbbbbbbbbbbb\" + \"cccccccccccccc\" + \"dddddddddd\")\n" + - " .append(\"aaaaaaa\" + \"bbbbbbbbbbbbb\" + \"cccccccccccccc\" + \"ddddddddd\");\n" + - " }\n" + - "}"; - formatSource(source); -} -/** - * https://bugs.eclipse.org/384959 - [formatter] Add line wrapping options for generics - */ -public void testBug384959a() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - String input = getCompilationUnit("Formatter", "", "test384959", "A_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test384959", "A_out1.java").getSource()); -} -/** - * https://bugs.eclipse.org/384959 - [formatter] Add line wrapping options for generics - */ -public void testBug384959b() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.alignment_for_parameterized_type_references = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; - String input = getCompilationUnit("Formatter", "", "test384959", "A_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test384959", "A_out2.java").getSource()); -} -/** - * https://bugs.eclipse.org/384959 - [formatter] Add line wrapping options for generics - */ -public void testBug384959c() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.alignment_for_type_arguments = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; - String input = getCompilationUnit("Formatter", "", "test384959", "A_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test384959", "A_out3.java").getSource()); -} -/** - * https://bugs.eclipse.org/384959 - [formatter] Add line wrapping options for generics - */ -public void testBug384959d() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.alignment_for_type_parameters = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; - String input = getCompilationUnit("Formatter", "", "test384959", "A_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test384959", "A_out4.java").getSource()); -} -/** - * https://bugs.eclipse.org/384959 - [formatter] Add line wrapping options for generics - */ -public void testBug384959e() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - int policy = Alignment.M_NEXT_SHIFTED_SPLIT + Alignment.M_FORCE; - this.formatterPrefs.alignment_for_parameterized_type_references = policy; - this.formatterPrefs.alignment_for_type_arguments = policy; - this.formatterPrefs.alignment_for_type_parameters = policy; - String input = getCompilationUnit("Formatter", "", "test384959", "A_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test384959", "A_out5.java").getSource()); -} -/** - * https://bugs.eclipse.org/384959 - [formatter] Add line wrapping options for generics - */ -public void testBug384959f() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE; - int policy = Alignment.M_NEXT_PER_LINE_SPLIT + Alignment.M_INDENT_ON_COLUMN + Alignment.M_FORCE; - this.formatterPrefs.alignment_for_parameterized_type_references = policy; - this.formatterPrefs.alignment_for_type_arguments = policy; - this.formatterPrefs.alignment_for_type_parameters = policy; - String input = getCompilationUnit("Formatter", "", "test384959", "A_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test384959", "A_out6.java").getSource()); -} -/** - * https://bugs.eclipse.org/384959 - [formatter] Add line wrapping options for generics - */ -public void testBug384959g() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.alignment_for_type_parameters = Alignment.M_COMPACT_SPLIT; - String source = - "public interface IteratedDescribeLinkList<\n" + - " T extends IteratedDescribeLinkList, E extends IteratedDescribeLink,\n" + - " A extends Iterated, B extends Iterated, C extends IteratedList,\n" + - " D extends IteratedList, F extends MasteredList,\n" + - " G extends MasteredList, H extends Mastered, I extends Mastered, X extends T, Y extends C,\n" + - " Z extends D, J extends F, K extends G> extends ObjectToObjectLinkList {\n" + - "}"; - formatSource(source); -} -/** - * https://bugs.eclipse.org/488642 - [formatter] IOOBE with block comment inside anonymous class - */ -public void testBug488642a() { - this.formatterPrefs.use_tabs_only_for_leading_indentations = true; - String source = - "public class Test {\n" + - " Object o = new Object() {\n" + - " int a = 0;\n" + - " /*\n" + - " * comment\n" + - " */\n" + - " int b = 9; /*\n" + - " * comment\n" + - " */\n" + - " String ssssssss = \"aaaaaaaaaaaaaaaaaaaaaaaa\" //\n" + - " + \"ddddddddddddddddddddddd\" /*\n" + - " * comment\n" + - " */;\n" + - " };\n" + - "}"; - formatSource(source); -} -/** - * https://bugs.eclipse.org/488642 - [formatter] IOOBE with block comment inside anonymous class - */ -public void testBug488642b() { - this.formatterPrefs.use_tabs_only_for_leading_indentations = true; - this.formatterPrefs.align_type_members_on_columns = true; - String source = - "public class Test {\n" + - " Object o = new Object() {\n" + - " int a = 0;\n" + - " /*\n" + - " * comment\n" + - " */\n" + - " int b = 9; /*\n" + - " * comment\n" + - " */\n" + - " String ssssssss = \"aaaaaaaaaaaaaaaaaaaaaaaa\" //\n" + - " + \"ddddddddddddddddddddddd\" /*\n" + - " * comment\n" + - " */;\n" + - " };\n" + - "}"; - formatSource(source); -} -/** - * https://bugs.eclipse.org/493296 - Eclipse formatter hangs when formatting with formatter.join_wrapped_lines=true - */ -public void testBug493296() throws JavaModelException { - setPageWidth80(); - String input = getCompilationUnit("Formatter", "", "test493296", "A_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test493296", "A_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/362260 - [formatter] New feature: count comment width from starting position - */ -public void testBug362260a() throws JavaModelException { - setPageWidth80(); - setFormatLineCommentOnFirstColumn(); - this.formatterPrefs.comment_line_length = 40; - this.formatterPrefs.comment_format_header = true; - this.formatterPrefs.comment_count_line_length_from_starting_position = true; - String input = getCompilationUnit("Formatter", "", "test362260", "A_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test362260", "A_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/362260 - [formatter] New feature: count comment width from starting position - */ -public void testBug362260b() throws JavaModelException { - setPageWidth80(); - this.formatterPrefs.comment_line_length = 40; - this.formatterPrefs.comment_format_header = true; - this.formatterPrefs.comment_count_line_length_from_starting_position = true; - String input = getCompilationUnit("Formatter", "", "test362260", "B_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test362260", "B_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/362260 - [formatter] New feature: count comment width from starting position - */ -public void testBug362260c() throws JavaModelException { - setPageWidth80(); - this.formatterPrefs.comment_line_length = 40; - this.formatterPrefs.comment_format_header = true; - this.formatterPrefs.comment_count_line_length_from_starting_position = true; - this.formatterPrefs.comment_new_lines_at_block_boundaries = false; - String input = getCompilationUnit("Formatter", "", "test362260", "C_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test362260", "C_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/362260 - [formatter] New feature: count comment width from starting position - */ -public void testBug362260d() throws JavaModelException { - setPageWidth80(); - this.formatterPrefs.comment_line_length = 40; - this.formatterPrefs.comment_format_header = true; - this.formatterPrefs.comment_count_line_length_from_starting_position = true; - String input = getCompilationUnit("Formatter", "", "test362260", "D_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test362260", "D_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/362260 - [formatter] New feature: count comment width from starting position - */ -public void testBug362260e() throws JavaModelException { - setPageWidth80(); - this.formatterPrefs.comment_line_length = 40; - this.formatterPrefs.comment_format_header = true; - this.formatterPrefs.comment_count_line_length_from_starting_position = true; - this.formatterPrefs.comment_new_lines_at_javadoc_boundaries = false; - String input = getCompilationUnit("Formatter", "", "test362260", "E_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test362260", "E_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/362260 - [formatter] New feature: count comment width from starting position - */ -public void testBug362260f() throws JavaModelException { - setPageWidth80(); - this.formatterPrefs.comment_line_length = 40; - this.formatterPrefs.comment_count_line_length_from_starting_position = true; - this.formatterPrefs.comment_preserve_white_space_between_code_and_line_comments = true; - String input = getCompilationUnit("Formatter", "", "test362260", "F_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test362260", "F_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/362260 - [formatter] New feature: count comment width from starting position - */ -public void testBug362260g() throws JavaModelException { - setPageWidth80(); - this.formatterPrefs.comment_line_length = 40; - this.formatterPrefs.comment_format_header = true; - this.formatterPrefs.comment_count_line_length_from_starting_position = true; - String input = getCompilationUnit("Formatter", "", "test362260", "G_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test362260", "G_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/506430 - [1.9] Formatter support for module-info.java - */ -public void testBug506430a() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_9); - setPageWidth80(); - String input = getCompilationUnit("Formatter", "", "test506430", "A_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test506430", "A_out.java") .getSource(), - CodeFormatter.K_MODULE_INFO | CodeFormatter.F_INCLUDE_COMMENTS); -} -/** - * https://bugs.eclipse.org/506430 - [1.9] Formatter support for module-info.java - */ -public void testBug506430b() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_9); - setPageWidth80(); - this.formatterPrefs.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE; - this.formatterPrefs.blank_lines_before_new_chunk = 2; - this.formatterPrefs.blank_lines_before_first_class_body_declaration = 3; - this.formatterPrefs.blank_lines_before_field = 1; - this.formatterPrefs.indent_body_declarations_compare_to_type_header = false; - this.formatterPrefs.insert_space_before_comma_in_multiple_field_declarations = true; - this.formatterPrefs.alignment_for_module_statements = Alignment.M_NEXT_PER_LINE_SPLIT; - this.formatterPrefs.insert_new_line_at_end_of_file_if_missing = true; - String input = getCompilationUnit("Formatter", "", "test506430", "B_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test506430", "B_out.java") .getSource(), - CodeFormatter.K_MODULE_INFO | CodeFormatter.F_INCLUDE_COMMENTS); -} -/** - * https://bugs.eclipse.org/506430 - [1.9] Formatter support for module-info.java - */ -public void testBug506430c() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_9); - setPageWidth80(); - String input = getCompilationUnit("Formatter", "", "test506430", "A_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test506430", "A_out.java") .getSource(), - CodeFormatter.K_UNKNOWN | CodeFormatter.F_INCLUDE_COMMENTS); -} - -/** - * https://bugs.eclipse.org/518235 - [1.8][formatter] Receiver parameter breaks whitespace rule - */ -public void testBug518235() throws JavaModelException { - String source = - "public class Base {\n" + - " class Base2 {\n" + - " Base2(Base Base.this) {\n" + - " }\n" + - " }\n" + - "\n" + - " T foo(@Deprecated Base this, final Base bar1, final Base bar2) {\n" + - " }\n" + - "}"; - formatSource(source); -} - -/** - * https://bugs.eclipse.org/128653 - [formatter] Improve tag description indentation in javadoc - */ -public void testBug128653a() throws JavaModelException { - this.formatterPrefs.comment_indent_root_tags = false; - this.formatterPrefs.comment_align_tags_names_descriptions = false; - this.formatterPrefs.comment_align_tags_descriptions_grouped = false; - this.formatterPrefs.comment_indent_parameter_description = false; - this.formatterPrefs.comment_insert_new_line_for_parameter = false; - String input = getCompilationUnit("Formatter", "", "test128653", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test128653", "A_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/128653 - [formatter] Improve tag description indentation in javadoc - */ -public void testBug128653b() throws JavaModelException { - this.formatterPrefs.comment_indent_root_tags = true; - this.formatterPrefs.comment_align_tags_names_descriptions = false; - this.formatterPrefs.comment_align_tags_descriptions_grouped = false; - this.formatterPrefs.comment_indent_parameter_description = false; - this.formatterPrefs.comment_insert_new_line_for_parameter = false; - String input = getCompilationUnit("Formatter", "", "test128653", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test128653", "B_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/128653 - [formatter] Improve tag description indentation in javadoc - */ -public void testBug128653c() throws JavaModelException { - this.formatterPrefs.comment_indent_root_tags = false; - this.formatterPrefs.comment_align_tags_names_descriptions = true; - this.formatterPrefs.comment_align_tags_descriptions_grouped = false; - this.formatterPrefs.comment_indent_parameter_description = false; - this.formatterPrefs.comment_insert_new_line_for_parameter = false; - String input = getCompilationUnit("Formatter", "", "test128653", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test128653", "C_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/128653 - [formatter] Improve tag description indentation in javadoc - */ -public void testBug128653d() throws JavaModelException { - this.formatterPrefs.comment_indent_root_tags = false; - this.formatterPrefs.comment_align_tags_names_descriptions = false; - this.formatterPrefs.comment_align_tags_descriptions_grouped = true; - this.formatterPrefs.comment_indent_parameter_description = false; - this.formatterPrefs.comment_insert_new_line_for_parameter = false; - String input = getCompilationUnit("Formatter", "", "test128653", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test128653", "D_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/128653 - [formatter] Improve tag description indentation in javadoc - */ -public void testBug128653e() throws JavaModelException { - this.formatterPrefs.comment_indent_root_tags = false; - this.formatterPrefs.comment_align_tags_names_descriptions = true; - this.formatterPrefs.comment_align_tags_descriptions_grouped = false; - this.formatterPrefs.comment_indent_parameter_description = true; - this.formatterPrefs.comment_insert_new_line_for_parameter = false; - String input = getCompilationUnit("Formatter", "", "test128653", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test128653", "E_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/128653 - [formatter] Improve tag description indentation in javadoc - */ -public void testBug128653f() throws JavaModelException { - this.formatterPrefs.comment_indent_root_tags = false; - this.formatterPrefs.comment_align_tags_names_descriptions = true; - this.formatterPrefs.comment_align_tags_descriptions_grouped = false; - this.formatterPrefs.comment_indent_parameter_description = false; - this.formatterPrefs.comment_insert_new_line_for_parameter = true; - String input = getCompilationUnit("Formatter", "", "test128653", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test128653", "F_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/128653 - [formatter] Improve tag description indentation in javadoc - */ -public void testBug128653g() throws JavaModelException { - this.formatterPrefs.comment_indent_root_tags = false; - this.formatterPrefs.comment_align_tags_names_descriptions = false; - this.formatterPrefs.comment_align_tags_descriptions_grouped = true; - this.formatterPrefs.comment_indent_parameter_description = true; - this.formatterPrefs.comment_insert_new_line_for_parameter = true; - String input = getCompilationUnit("Formatter", "", "test128653", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test128653", "G_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/128653 - [formatter] Improve tag description indentation in javadoc - */ -public void testBug128653h() throws JavaModelException { - this.formatterPrefs.comment_indent_root_tags = false; - this.formatterPrefs.comment_align_tags_names_descriptions = false; - this.formatterPrefs.comment_align_tags_descriptions_grouped = false; - this.formatterPrefs.comment_indent_parameter_description = true; - this.formatterPrefs.comment_insert_new_line_for_parameter = true; - String input = getCompilationUnit("Formatter", "", "test128653", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test128653", "H_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/128653 - [formatter] Improve tag description indentation in javadoc - */ -public void testBug128653i() throws JavaModelException { - this.formatterPrefs.comment_indent_root_tags = true; - this.formatterPrefs.comment_align_tags_names_descriptions = false; - this.formatterPrefs.comment_align_tags_descriptions_grouped = false; - this.formatterPrefs.comment_indent_parameter_description = true; - this.formatterPrefs.comment_insert_new_line_for_parameter = false; - String input = getCompilationUnit("Formatter", "", "test128653", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test128653", "I_out.java").getSource()); -} - -/** - * https://bugs.eclipse.org/104910 - [formatter] add "keep simple for/while on one line" option - */ -public void testBug104910a() throws JavaModelException { - this.formatterPrefs.keep_simple_for_body_on_same_line = true; - String input = getCompilationUnit("Formatter", "", "test104910", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test104910", "A_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/104910 - [formatter] add "keep simple for/while on one line" option - */ -public void testBug104910b() throws JavaModelException { - this.formatterPrefs.keep_simple_while_body_on_same_line = true; - String input = getCompilationUnit("Formatter", "", "test104910", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test104910", "B_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/104910 - [formatter] add "keep simple for/while on one line" option - */ -public void testBug104910c() throws JavaModelException { - this.formatterPrefs.keep_simple_do_while_body_on_same_line = true; - String input = getCompilationUnit("Formatter", "", "test104910", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test104910", "C_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/104910 - [formatter] add "keep simple for/while on one line" option - */ -public void testBug104910d() throws JavaModelException { - this.formatterPrefs.keep_simple_for_body_on_same_line = true; - this.formatterPrefs.keep_simple_while_body_on_same_line = true; - this.formatterPrefs.keep_simple_do_while_body_on_same_line = true; - this.formatterPrefs.keep_simple_if_on_one_line = true; - this.formatterPrefs.alignment_for_compact_if = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; - this.formatterPrefs.alignment_for_compact_loop = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; - this.formatterPrefs.use_tabs_only_for_leading_indentations = true; - String input = getCompilationUnit("Formatter", "", "test104910", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test104910", "D_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/104910 - [formatter] add "keep simple for/while on one line" option - */ -public void testBug104910e() throws JavaModelException { - this.formatterPrefs.keep_simple_for_body_on_same_line = true; - this.formatterPrefs.keep_simple_while_body_on_same_line = true; - this.formatterPrefs.keep_simple_do_while_body_on_same_line = true; - this.formatterPrefs.keep_simple_if_on_one_line = true; - this.formatterPrefs.use_tabs_only_for_leading_indentations = true; - this.formatterPrefs.page_width = 55; - String input = getCompilationUnit("Formatter", "", "test104910", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test104910", "E_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/104910 - [formatter] add "keep simple for/while on one line" option - */ -public void testBug104910f() throws JavaModelException { - this.formatterPrefs.keep_simple_for_body_on_same_line = true; - this.formatterPrefs.keep_simple_while_body_on_same_line = true; - this.formatterPrefs.keep_simple_do_while_body_on_same_line = true; - this.formatterPrefs.keep_simple_if_on_one_line = true; - this.formatterPrefs.alignment_for_compact_if = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; - this.formatterPrefs.alignment_for_compact_loop = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; - this.formatterPrefs.use_tabs_only_for_leading_indentations = true; - String input = getCompilationUnit("Formatter", "", "test104910", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test104910", "F_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/104910 - [formatter] add "keep simple for/while on one line" option - */ -public void testBug104910g() throws JavaModelException { - this.formatterPrefs.keep_simple_for_body_on_same_line = true; - this.formatterPrefs.keep_simple_while_body_on_same_line = true; - this.formatterPrefs.keep_simple_do_while_body_on_same_line = true; - this.formatterPrefs.keep_simple_if_on_one_line = true; - this.formatterPrefs.alignment_for_compact_if = Alignment.M_NO_ALIGNMENT; - this.formatterPrefs.page_width = 40; - String input = getCompilationUnit("Formatter", "", "test104910", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test104910", "G_out.java").getSource()); -} - -/** - * https://bugs.eclipse.org/530756 - [formatter] Align fields in columns: add option to use spaces - */ -public void testBug530756a() throws JavaModelException { - this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.TAB; - this.formatterPrefs.align_type_members_on_columns = true; - String input = getCompilationUnit("Formatter", "", "test530756", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test530756", "A_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/530756 - [formatter] Align fields in columns: add option to use spaces - */ -public void testBug530756b() throws JavaModelException { - this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.TAB; - this.formatterPrefs.align_type_members_on_columns = true; - this.formatterPrefs.align_with_spaces = true; - String input = getCompilationUnit("Formatter", "", "test530756", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test530756", "B_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/530756 - [formatter] Align fields in columns: add option to use spaces - */ -public void testBug530756c() throws JavaModelException { - this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.MIXED; - this.formatterPrefs.indentation_size = 6; - this.formatterPrefs.align_type_members_on_columns = true; - this.formatterPrefs.align_with_spaces = true; - String input = getCompilationUnit("Formatter", "", "test530756", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test530756", "C_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/530756 - [formatter] Align fields in columns: add option to use spaces - */ -public void testBug530756d() throws JavaModelException { - this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE; - this.formatterPrefs.align_type_members_on_columns = true; - this.formatterPrefs.align_with_spaces = true; - String input = getCompilationUnit("Formatter", "", "test530756", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test530756", "D_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/530756 - [formatter] Align fields in columns: add option to use spaces - */ -public void testBug530756e() throws JavaModelException { - this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE; - this.formatterPrefs.align_type_members_on_columns = true; - this.formatterPrefs.align_with_spaces = false; - String input = getCompilationUnit("Formatter", "", "test530756", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test530756", "E_out.java").getSource()); -} - -/** - * https://bugs.eclipse.org/131292 - [format] align assignments in columns - */ -public void testBug131292a() throws JavaModelException { - this.formatterPrefs.align_type_members_on_columns = true; - String input = getCompilationUnit("Formatter", "", "test131292", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test131292", "A_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/131292 - [format] align assignments in columns - */ -public void testBug131292b() throws JavaModelException { - this.formatterPrefs.align_variable_declarations_on_columns = true; - String input = getCompilationUnit("Formatter", "", "test131292", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test131292", "B_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/131292 - [format] align assignments in columns - */ -public void testBug131292c() throws JavaModelException { - this.formatterPrefs.align_assignment_statements_on_columns = true; - String input = getCompilationUnit("Formatter", "", "test131292", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test131292", "C_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/131292 - [format] align assignments in columns - */ -public void testBug131292d() throws JavaModelException { - this.formatterPrefs.align_type_members_on_columns = true; - this.formatterPrefs.align_variable_declarations_on_columns = true; - this.formatterPrefs.align_assignment_statements_on_columns = true; - this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE; - String input = getCompilationUnit("Formatter", "", "test131292", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test131292", "D_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/131292 - [format] align assignments in columns - */ -public void testBug131292e() throws JavaModelException { - this.formatterPrefs.align_type_members_on_columns = true; - this.formatterPrefs.align_variable_declarations_on_columns = true; - this.formatterPrefs.align_assignment_statements_on_columns = true; - this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.MIXED; - this.formatterPrefs.align_fields_grouping_blank_lines = 1; - String input = getCompilationUnit("Formatter", "", "test131292", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test131292", "E_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/131292 - [format] align assignments in columns - */ -public void testBug131292f() throws JavaModelException { - this.formatterPrefs.align_type_members_on_columns = true; - this.formatterPrefs.align_variable_declarations_on_columns = true; - this.formatterPrefs.align_assignment_statements_on_columns = true; - this.formatterPrefs.align_with_spaces = true; - this.formatterPrefs.align_fields_grouping_blank_lines = 2; - String input = getCompilationUnit("Formatter", "", "test131292", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test131292", "F_out.java").getSource()); -} - -/** - * https://bugs.eclipse.org/205973 - [formatter] Allow to keep simple methods on one line (for exemple simple getter or setter) - */ -public void testBug205973a() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.keep_annotation_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - this.formatterPrefs.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - this.formatterPrefs.keep_if_then_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - this.formatterPrefs.keep_lambda_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - this.formatterPrefs.keep_loop_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - this.formatterPrefs.keep_code_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_enum_constant_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_enum_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_simple_getter_setter_on_one_line = false; - this.formatterPrefs.keep_guardian_clause_on_one_line = false; - String input = getCompilationUnit("Formatter", "", "test205973", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test205973", "A_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/205973 - [formatter] Allow to keep simple methods on one line (for exemple simple getter or setter) - */ -public void testBug205973b() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.keep_annotation_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_if_then_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_lambda_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM; - this.formatterPrefs.keep_loop_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM; - this.formatterPrefs.keep_code_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_enum_constant_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - this.formatterPrefs.keep_enum_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - this.formatterPrefs.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_simple_getter_setter_on_one_line = true; - this.formatterPrefs.keep_guardian_clause_on_one_line = false; - String input = getCompilationUnit("Formatter", "", "test205973", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test205973", "B_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/205973 - [formatter] Allow to keep simple methods on one line (for exemple simple getter or setter) - */ -public void testBug205973c() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.keep_annotation_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM; - this.formatterPrefs.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM; - this.formatterPrefs.keep_if_then_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_lambda_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_loop_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_code_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - this.formatterPrefs.keep_enum_constant_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_enum_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM; - this.formatterPrefs.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - this.formatterPrefs.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - this.formatterPrefs.keep_simple_getter_setter_on_one_line = false; - this.formatterPrefs.keep_guardian_clause_on_one_line = true; - String input = getCompilationUnit("Formatter", "", "test205973", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test205973", "C_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/205973 - [formatter] Allow to keep simple methods on one line (for exemple simple getter or setter) - */ -public void testBug205973d() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.keep_annotation_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - this.formatterPrefs.keep_if_then_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_lambda_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM; - this.formatterPrefs.keep_loop_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_code_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - this.formatterPrefs.keep_enum_constant_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM; - this.formatterPrefs.keep_enum_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM; - this.formatterPrefs.keep_simple_getter_setter_on_one_line = false; - this.formatterPrefs.keep_guardian_clause_on_one_line = false; - String input = getCompilationUnit("Formatter", "", "test205973", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test205973", "D_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/205973 - [formatter] Allow to keep simple methods on one line (for exemple simple getter or setter) - */ -public void testBug205973e() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.keep_annotation_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - this.formatterPrefs.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_if_then_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - this.formatterPrefs.keep_lambda_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_loop_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - this.formatterPrefs.keep_code_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_enum_constant_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - this.formatterPrefs.keep_enum_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - this.formatterPrefs.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_simple_getter_setter_on_one_line = true; - this.formatterPrefs.keep_guardian_clause_on_one_line = true; - String input = getCompilationUnit("Formatter", "", "test205973", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test205973", "E_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/205973 - [formatter] Allow to keep simple methods on one line (for exemple simple getter or setter) - */ -public void testBug205973f() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.keep_annotation_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - this.formatterPrefs.keep_if_then_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - this.formatterPrefs.keep_lambda_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_loop_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM; - this.formatterPrefs.keep_code_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_enum_constant_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - this.formatterPrefs.keep_enum_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - this.formatterPrefs.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - this.formatterPrefs.keep_simple_getter_setter_on_one_line = false; - this.formatterPrefs.keep_guardian_clause_on_one_line = false; - String input = getCompilationUnit("Formatter", "", "test205973", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test205973", "F_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/205973 - [formatter] Allow to keep simple methods on one line (for exemple simple getter or setter) - */ -public void testBug205973g() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.keep_annotation_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - this.formatterPrefs.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_if_then_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM; - this.formatterPrefs.keep_lambda_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - this.formatterPrefs.keep_loop_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_code_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - this.formatterPrefs.keep_enum_constant_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_enum_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM; - this.formatterPrefs.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - this.formatterPrefs.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_simple_getter_setter_on_one_line = false; - this.formatterPrefs.keep_guardian_clause_on_one_line = false; - String input = getCompilationUnit("Formatter", "", "test205973", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test205973", "G_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/205973 - [formatter] Allow to keep simple methods on one line (for exemple simple getter or setter) - */ -public void testBug205973h() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.keep_annotation_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_PRESERVE; - this.formatterPrefs.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_PRESERVE; - this.formatterPrefs.keep_if_then_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_PRESERVE; - this.formatterPrefs.keep_lambda_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_PRESERVE; - this.formatterPrefs.keep_loop_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_PRESERVE; - this.formatterPrefs.keep_code_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; - this.formatterPrefs.keep_enum_constant_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_PRESERVE; - this.formatterPrefs.keep_enum_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_PRESERVE; - this.formatterPrefs.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_PRESERVE; - this.formatterPrefs.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_PRESERVE; - this.formatterPrefs.keep_simple_getter_setter_on_one_line = false; - this.formatterPrefs.keep_guardian_clause_on_one_line = false; - this.formatterPrefs.align_type_members_on_columns = true; - this.formatterPrefs.align_variable_declarations_on_columns = true; - this.formatterPrefs.align_assignment_statements_on_columns = true; - String input = getCompilationUnit("Formatter", "", "test205973", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test205973", "H_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/205973 - [formatter] Allow to keep simple methods on one line (for exemple simple getter or setter) - */ -public void testBug205973i() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.page_width = 50; - this.formatterPrefs.use_tabs_only_for_leading_indentations = true; - this.formatterPrefs.keep_annotation_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - this.formatterPrefs.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - this.formatterPrefs.keep_if_then_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - this.formatterPrefs.keep_lambda_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - this.formatterPrefs.keep_loop_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - this.formatterPrefs.keep_code_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; - this.formatterPrefs.keep_enum_constant_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - this.formatterPrefs.keep_enum_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - this.formatterPrefs.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - this.formatterPrefs.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - this.formatterPrefs.keep_simple_getter_setter_on_one_line = false; - this.formatterPrefs.keep_guardian_clause_on_one_line = false; - String input = getCompilationUnit("Formatter", "", "test205973", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test205973", "I_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/205973 - [formatter] Allow to keep simple methods on one line (for exemple simple getter or setter) - */ -public void testBug205973j() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - String input = getCompilationUnit("Formatter", "", "test205973", "J_in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test205973", "J_out.java").getSource()); -} - -/** - * https://bugs.eclipse.org/541133 - [formatter] javadoc: no indent of @return description - */ -public void testBug541133a() { - this.formatterPrefs.comment_align_tags_descriptions_grouped = false; - this.formatterPrefs.comment_indent_parameter_description = false; - this.formatterPrefs.comment_indent_tag_description = true; - String source = - "class C {\n" + - " /**\n" + - " * @param bar param description should NOT get additional indentation when it's wrapped\n" + - " * @return return description should get additional indentation when it's wrapped\n" + - " */\n" + - " String foo(String bar) {\n" + - " }\n" + - "}"; - formatSource(source, - "class C {\n" + - " /**\n" + - " * @param bar param description should NOT get additional indentation when it's\n" + - " * wrapped\n" + - " * @return return description should get additional indentation when it's\n" + - " * wrapped\n" + - " */\n" + - " String foo(String bar) {\n" + - " }\n" + - "}"); -} -/** - * https://bugs.eclipse.org/541133 - [formatter] javadoc: no indent of @return description - */ -public void testBug541133b() { - this.formatterPrefs.comment_indent_root_tags = true; - this.formatterPrefs.comment_indent_parameter_description = false; - this.formatterPrefs.comment_indent_tag_description = true; - String source = - "class C {\n" + - " /**\n" + - " * @deprecated Do not use this class, it's only to test formatting on. One two three four five six seven eight nine ten\n" + - " */\n" + - " void foo() {\n" + - " }\n" + - "}"; - formatSource(source, - "class C {\n" + - " /**\n" + - " * @deprecated Do not use this class, it's only to test formatting on. One two\n" + - " * three four five six seven eight nine ten\n" + - " */\n" + - " void foo() {\n" + - " }\n" + - "}"); -} -/** - * https://bugs.eclipse.org/541133 - [formatter] javadoc: no indent of @return description - */ -public void testBug541133c() { - this.formatterPrefs.comment_indent_tag_description = true; - String source = - "/**\n" + - " * Mensagens SMTP tem o seguinte formato:\n" + - " * \n" + - " *
\n" +
-		" * resposta de uma linha só:\n" +
-		" * 
\n" + - " * \n" + - " * {@link java.lang.String a simple string}.\n" + - " * \n" + - " * @deprecated Mensagens SMTP tem o seguinte formato:\n" + - " * \n" + - " *
\n" +
-		" *                 resposta de uma linha só:\n" +
-		" *                 
\n" + - " */"; - formatSource(source); -} -/** - * https://bugs.eclipse.org/541133 - [formatter] javadoc: no indent of @return description - */ -public void testBug541133d() { - String source = - "/**\n" + - " * @return something
\n" +
-		" * class Runnable {\n" +
-		" * 	// Hello really bad Ganymede formatter !!!\n" +
-		" * 	// Shit happens when somebody tries to change a running system\n" +
-		" * }
something\n" + - " */"; - formatSource(source, - "/**\n" + - " * @return something\n" + - " * \n" + - " *
\n" +
-		" *         class Runnable {\n" +
-		" *         	// Hello really bad Ganymede formatter !!!\n" +
-		" *         	// Shit happens when somebody tries to change a running system\n" +
-		" *         }\n" +
-		" *         
\n" + - " * \n" + - " * something\n" + - " */"); -} - -/** - * https://bugs.eclipse.org/543079 - [formatter] wrapping binary expressions: separate options for operator types - */ -public void testBug543079a() throws JavaModelException { - this.formatterPrefs.page_width = 80; - this.formatterPrefs.alignment_for_multiplicative_operator = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; - this.formatterPrefs.wrap_before_multiplicative_operator = false; - String input = getCompilationUnit("Formatter", "", "test543079", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test543079", "A_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/543079 - [formatter] wrapping binary expressions: separate options for operator types - */ -public void testBug543079b() throws JavaModelException { - this.formatterPrefs.page_width = 80; - this.formatterPrefs.alignment_for_additive_operator = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; - this.formatterPrefs.wrap_before_additive_operator = false; - String input = getCompilationUnit("Formatter", "", "test543079", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test543079", "B_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/543079 - [formatter] wrapping binary expressions: separate options for operator types - */ -public void testBug543079c() throws JavaModelException { - this.formatterPrefs.page_width = 80; - this.formatterPrefs.alignment_for_string_concatenation = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; - this.formatterPrefs.wrap_before_string_concatenation = false; - String input = getCompilationUnit("Formatter", "", "test543079", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test543079", "C_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/543079 - [formatter] wrapping binary expressions: separate options for operator types - */ -public void testBug543079d() throws JavaModelException { - this.formatterPrefs.page_width = 80; - this.formatterPrefs.alignment_for_shift_operator = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; - this.formatterPrefs.wrap_before_shift_operator = false; - String input = getCompilationUnit("Formatter", "", "test543079", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test543079", "D_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/543079 - [formatter] wrapping binary expressions: separate options for operator types - */ -public void testBug543079e() throws JavaModelException { - this.formatterPrefs.page_width = 80; - this.formatterPrefs.alignment_for_relational_operator = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; - this.formatterPrefs.wrap_before_relational_operator = false; - String input = getCompilationUnit("Formatter", "", "test543079", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test543079", "E_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/543079 - [formatter] wrapping binary expressions: separate options for operator types - */ -public void testBug543079f() throws JavaModelException { - this.formatterPrefs.page_width = 80; - this.formatterPrefs.alignment_for_bitwise_operator = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; - this.formatterPrefs.wrap_before_bitwise_operator = false; - String input = getCompilationUnit("Formatter", "", "test543079", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test543079", "F_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/543079 - [formatter] wrapping binary expressions: separate options for operator types - */ -public void testBug543079g() throws JavaModelException { - this.formatterPrefs.page_width = 80; - this.formatterPrefs.alignment_for_logical_operator = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; - this.formatterPrefs.wrap_before_logical_operator = false; - String input = getCompilationUnit("Formatter", "", "test543079", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test543079", "G_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/159565 - [formatter] Separate white space preferences for separate operators - */ -public void testBug159565a() throws JavaModelException { - this.formatterPrefs.insert_space_before_multiplicative_operator = false; - this.formatterPrefs.insert_space_before_bitwise_operator = false; - String input = getCompilationUnit("Formatter", "", "test159565", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test159565", "A_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/159565 - [formatter] Separate white space preferences for separate operators - */ -public void testBug159565b() throws JavaModelException { - this.formatterPrefs.insert_space_after_multiplicative_operator = false; - this.formatterPrefs.insert_space_after_additive_operator = false; - String input = getCompilationUnit("Formatter", "", "test159565", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test159565", "B_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/159565 - [formatter] Separate white space preferences for separate operators - */ -public void testBug159565c() throws JavaModelException { - this.formatterPrefs.insert_space_before_additive_operator = false; - this.formatterPrefs.insert_space_before_logical_operator = false; - String input = getCompilationUnit("Formatter", "", "test159565", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test159565", "C_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/159565 - [formatter] Separate white space preferences for separate operators - */ -public void testBug159565d() throws JavaModelException { - this.formatterPrefs.insert_space_before_string_concatenation = false; - this.formatterPrefs.insert_space_after_bitwise_operator = false; - String input = getCompilationUnit("Formatter", "", "test159565", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test159565", "D_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/159565 - [formatter] Separate white space preferences for separate operators - */ -public void testBug159565e() throws JavaModelException { - this.formatterPrefs.insert_space_after_string_concatenation = false; - this.formatterPrefs.insert_space_before_shift_operator = false; - String input = getCompilationUnit("Formatter", "", "test159565", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test159565", "E_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/159565 - [formatter] Separate white space preferences for separate operators - */ -public void testBug159565f() throws JavaModelException { - this.formatterPrefs.insert_space_after_shift_operator = false; - this.formatterPrefs.insert_space_after_relational_operator = false; - String input = getCompilationUnit("Formatter", "", "test159565", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test159565", "F_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/159565 - [formatter] Separate white space preferences for separate operators - */ -public void testBug159565g() throws JavaModelException { - this.formatterPrefs.insert_space_before_relational_operator = false; - this.formatterPrefs.insert_space_after_logical_operator = false; - String input = getCompilationUnit("Formatter", "", "test159565", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test159565", "G_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/541011 - [formatter] Option to wrap chained conditionals as one group - */ -public void testBug541011a() throws JavaModelException { - this.formatterPrefs.page_width = 80; - String input = getCompilationUnit("Formatter", "", "test541011", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test541011", "A_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/541011 - [formatter] Option to wrap chained conditionals as one group - */ -public void testBug541011b() throws JavaModelException { - this.formatterPrefs.page_width = 80; - this.formatterPrefs.alignment_for_conditional_expression_chain = Alignment.M_COMPACT_SPLIT; - String input = getCompilationUnit("Formatter", "", "test541011", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test541011", "B_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/541011 - [formatter] Option to wrap chained conditionals as one group - */ -public void testBug541011c() throws JavaModelException { - this.formatterPrefs.page_width = 80; - this.formatterPrefs.alignment_for_conditional_expression_chain = Alignment.M_ONE_PER_LINE_SPLIT; - String input = getCompilationUnit("Formatter", "", "test541011", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test541011", "C_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/541011 - [formatter] Option to wrap chained conditionals as one group - */ -public void testBug541011d() throws JavaModelException { - this.formatterPrefs.page_width = 80; - this.formatterPrefs.alignment_for_conditional_expression_chain = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; - String input = getCompilationUnit("Formatter", "", "test541011", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test541011", "D_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/541011 - [formatter] Option to wrap chained conditionals as one group - */ -public void testBug541011e() throws JavaModelException { - this.formatterPrefs.page_width = 80; - this.formatterPrefs.alignment_for_conditional_expression_chain = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; - this.formatterPrefs.alignment_for_conditional_expression = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; - String input = getCompilationUnit("Formatter", "", "test541011", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test541011", "E_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/541011 - [formatter] Option to wrap chained conditionals as one group - */ -public void testBug541011f() throws JavaModelException { - this.formatterPrefs.page_width = 80; - this.formatterPrefs.alignment_for_conditional_expression_chain = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; - this.formatterPrefs.alignment_for_conditional_expression = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; - String input = getCompilationUnit("Formatter", "", "test541011", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test541011", "F_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/541011 - [formatter] Option to wrap chained conditionals as one group - */ -public void testBug541011g() throws JavaModelException { - this.formatterPrefs.page_width = 80; - this.formatterPrefs.alignment_for_conditional_expression = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; - String input = getCompilationUnit("Formatter", "", "test541011", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test541011", "G_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/543818 - [12] Formatter Support for Switch Expressions - */ -public void testBug543818a() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_14); - this.formatterPrefs.insert_space_before_comma_in_switch_case_expressions = true; - this.formatterPrefs.insert_space_before_colon_in_case = true; - this.formatterPrefs.indent_switchstatements_compare_to_switch = true; - String input = getCompilationUnit("Formatter", "", "test543818", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test543818", "A_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/543818 - [12] Formatter Support for Switch Expressions - */ -public void testBug543818b() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_14); - this.formatterPrefs.insert_space_after_comma_in_switch_case_expressions = false; - this.formatterPrefs.insert_space_before_closing_paren_in_switch = true; - this.formatterPrefs.indent_switchstatements_compare_to_cases = false; - String input = getCompilationUnit("Formatter", "", "test543818", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test543818", "B_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/543818 - [12] Formatter Support for Switch Expressions - */ -public void testBug543818c() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_14); - this.formatterPrefs.insert_space_before_arrow_in_switch_case = false; - this.formatterPrefs.insert_space_before_opening_paren_in_switch = false; - this.formatterPrefs.indent_breaks_compare_to_cases = false; - String input = getCompilationUnit("Formatter", "", "test543818", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test543818", "C_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/543818 - [12] Formatter Support for Switch Expressions - */ -public void testBug543818d() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_14); - this.formatterPrefs.insert_space_after_arrow_in_switch_case = false; - this.formatterPrefs.insert_space_after_opening_paren_in_switch = true; - this.formatterPrefs.insert_space_before_opening_brace_in_block = false; - this.formatterPrefs.brace_position_for_switch = DefaultCodeFormatterConstants.NEXT_LINE; - String input = getCompilationUnit("Formatter", "", "test543818", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test543818", "D_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/543818 - [12] Formatter Support for Switch Expressions - */ -public void testBug543818e() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_14); - this.formatterPrefs.insert_space_before_arrow_in_switch_default = false; - this.formatterPrefs.insert_space_before_colon_in_default = true; - this.formatterPrefs.parenthesis_positions_in_switch_statement = DefaultCodeFormatterConstants.SEPARATE_LINES; - String input = getCompilationUnit("Formatter", "", "test543818", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test543818", "E_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/543818 - [12] Formatter Support for Switch Expressions - */ -public void testBug543818f() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_14); - this.formatterPrefs.insert_space_after_arrow_in_switch_default = false; - this.formatterPrefs.insert_space_before_opening_brace_in_switch = false; - this.formatterPrefs.insert_space_before_opening_brace_in_block = false; - String input = getCompilationUnit("Formatter", "", "test543818", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test543818", "F_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/543818 - [12] Formatter Support for Switch Expressions - */ -public void testBug543818g() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_14); - String input = getCompilationUnit("Formatter", "", "test543818", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test543818", "G_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/549249 - [formatter] Extend Blank Lines settings to remove excess lines - */ -public void testBug549249a() throws JavaModelException { - this.formatterPrefs.number_of_empty_lines_to_preserve = 4; - this.formatterPrefs.blank_lines_after_imports = ~2; - String input = getCompilationUnit("Formatter", "", "test549249", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test549249", "A_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/549249 - [formatter] Extend Blank Lines settings to remove excess lines - */ -public void testBug549249b() throws JavaModelException { - this.formatterPrefs.number_of_empty_lines_to_preserve = 4; - this.formatterPrefs.blank_lines_after_package = ~1; - String input = getCompilationUnit("Formatter", "", "test549249", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test549249", "B_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/549249 - [formatter] Extend Blank Lines settings to remove excess lines - */ -public void testBug549249c() throws JavaModelException { - this.formatterPrefs.number_of_empty_lines_to_preserve = 4; - this.formatterPrefs.blank_lines_at_beginning_of_method_body = ~0; - String input = getCompilationUnit("Formatter", "", "test549249", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test549249", "C_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/549249 - [formatter] Extend Blank Lines settings to remove excess lines - */ -public void testBug549249d() throws JavaModelException { - this.formatterPrefs.number_of_empty_lines_to_preserve = 4; - this.formatterPrefs.blank_lines_before_field = ~3; - String input = getCompilationUnit("Formatter", "", "test549249", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test549249", "D_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/549249 - [formatter] Extend Blank Lines settings to remove excess lines - */ -public void testBug549249e() throws JavaModelException { - this.formatterPrefs.number_of_empty_lines_to_preserve = 4; - this.formatterPrefs.blank_lines_before_first_class_body_declaration = ~2; - String input = getCompilationUnit("Formatter", "", "test549249", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test549249", "E_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/549249 - [formatter] Extend Blank Lines settings to remove excess lines - */ -public void testBug549249f() throws JavaModelException { - this.formatterPrefs.number_of_empty_lines_to_preserve = 4; - this.formatterPrefs.blank_lines_before_imports = ~1; - String input = getCompilationUnit("Formatter", "", "test549249", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test549249", "F_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/549249 - [formatter] Extend Blank Lines settings to remove excess lines - */ -public void testBug549249g() throws JavaModelException { - this.formatterPrefs.number_of_empty_lines_to_preserve = 4; - this.formatterPrefs.blank_lines_before_member_type = ~0; - String input = getCompilationUnit("Formatter", "", "test549249", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test549249", "G_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/549249 - [formatter] Extend Blank Lines settings to remove excess lines - */ -public void testBug549249h() throws JavaModelException { - this.formatterPrefs.number_of_empty_lines_to_preserve = 4; - this.formatterPrefs.blank_lines_before_method = ~3; - String input = getCompilationUnit("Formatter", "", "test549249", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test549249", "H_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/549249 - [formatter] Extend Blank Lines settings to remove excess lines - */ -public void testBug549249i() throws JavaModelException { - this.formatterPrefs.number_of_empty_lines_to_preserve = 4; - this.formatterPrefs.blank_lines_before_new_chunk = ~2; - String input = getCompilationUnit("Formatter", "", "test549249", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test549249", "I_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/549249 - [formatter] Extend Blank Lines settings to remove excess lines - */ -public void testBug549249j() throws JavaModelException { - this.formatterPrefs.number_of_empty_lines_to_preserve = 4; - this.formatterPrefs.blank_lines_before_package = ~1; - String input = getCompilationUnit("Formatter", "", "test549249", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test549249", "J_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/549249 - [formatter] Extend Blank Lines settings to remove excess lines - */ -public void testBug549249k() throws JavaModelException { - this.formatterPrefs.number_of_empty_lines_to_preserve = 4; - this.formatterPrefs.blank_lines_between_import_groups = ~1; - String input = getCompilationUnit("Formatter", "", "test549249", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test549249", "K_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/549249 - [formatter] Extend Blank Lines settings to remove excess lines - */ -public void testBug549249l() throws JavaModelException { - this.formatterPrefs.number_of_empty_lines_to_preserve = 4; - this.formatterPrefs.blank_lines_between_type_declarations = ~3; - String input = getCompilationUnit("Formatter", "", "test549249", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test549249", "L_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/169131 - [formatter] Code formatter: blank lines after last declaration - */ -public void testBug169131a() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.number_of_empty_lines_to_preserve = 3; - this.formatterPrefs.blank_lines_after_last_class_body_declaration = 2; - String input = getCompilationUnit("Formatter", "", "test169131", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test169131", "A_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/169131 - [formatter] Code formatter: blank lines after last declaration - */ -public void testBug169131b() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.number_of_empty_lines_to_preserve = 3; - this.formatterPrefs.blank_lines_after_last_class_body_declaration = ~1; - String input = getCompilationUnit("Formatter", "", "test169131", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test169131", "B_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/169131 - [formatter] Code formatter: blank lines after last declaration - */ -public void testBug169131c() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_9); - this.formatterPrefs.blank_lines_after_last_class_body_declaration = 1; - String input = - "module aaaaaaaaaa.bbbbbbbbbb {\n" + - " requires aaaaaaaaaa.cccccccccc; // a comment\n" + - "}"; - formatSource(input, - "module aaaaaaaaaa.bbbbbbbbbb {\n" + - " requires aaaaaaaaaa.cccccccccc; // a comment\n" + - "\n" + - "}", - CodeFormatter.K_MODULE_INFO | CodeFormatter.F_INCLUDE_COMMENTS); -} -/** - * https://bugs.eclipse.org/169131 - [formatter] Code formatter: blank lines after last declaration - */ -public void testBug169131d() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_9); - this.formatterPrefs.blank_lines_after_last_class_body_declaration = ~0; - String input = - "module aaaaaaaaaa.bbbbbbbbbb {\n" + - " requires aaaaaaaaaa.cccccccccc;\n" + - "\n" + - "}"; - formatSource(input, - "module aaaaaaaaaa.bbbbbbbbbb {\n" + - " requires aaaaaaaaaa.cccccccccc;\n" + - "}", - CodeFormatter.K_MODULE_INFO | CodeFormatter.F_INCLUDE_COMMENTS); -} -/** - * https://bugs.eclipse.org/522089 - [formatter] Provide support for blank line before end of method - */ -public void testBug522089a() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.number_of_empty_lines_to_preserve = 3; - this.formatterPrefs.blank_lines_at_end_of_method_body = 2; - this.formatterPrefs.blank_lines_before_new_chunk = 0; - String input = getCompilationUnit("Formatter", "", "test522089", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test522089", "A_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/522089 - [formatter] Provide support for blank line before end of method - */ -public void testBug522089b() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_8); - this.formatterPrefs.number_of_empty_lines_to_preserve = 3; - this.formatterPrefs.blank_lines_at_end_of_method_body = ~0; - this.formatterPrefs.blank_lines_before_new_chunk = 0; - String input = getCompilationUnit("Formatter", "", "test522089", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test522089", "B_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/549774 - [formatter] Change semantics of Blank lines before member declarations: 'before' -> 'between' - */ -public void testBug549774() throws JavaModelException { - this.formatterPrefs.blank_lines_before_new_chunk = 1; - this.formatterPrefs.blank_lines_before_field = 2; - this.formatterPrefs.blank_lines_before_method = 3; - String input = - "class C {\n" + - " int a;\n" + - " String s;\n" + - " void foo() {}\n" + - " String bar(int a) {}\n" + - "}"; - formatSource(input, - "class C {\n" + - " int a;\n" + - "\n" + - "\n" + - " String s;\n" + - "\n" + - " void foo() {\n" + - " }\n" + - "\n" + - "\n" + - "\n" + - " String bar(int a) {\n" + - " }\n" + - "}"); -} -/** - * https://bugs.eclipse.org/214283 - [formatter] Blank lines option should consider a virtual/interface method - */ -public void testBug214283a() throws JavaModelException { - this.formatterPrefs.blank_lines_before_abstract_method= 2; - this.formatterPrefs.blank_lines_before_method= 0; - String input = getCompilationUnit("Formatter", "", "test214283", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test214283", "A_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/214283 - [formatter] Blank lines option should consider a virtual/interface method - */ -public void testBug214283b() throws JavaModelException { - this.formatterPrefs.blank_lines_before_abstract_method= ~0; - this.formatterPrefs.blank_lines_before_method= 1; - String input = getCompilationUnit("Formatter", "", "test214283", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test214283", "B_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/214283 - [formatter] Blank lines option should consider a virtual/interface method - */ -public void testBug214283c() throws JavaModelException { - this.formatterPrefs.blank_lines_before_abstract_method= 0; - this.formatterPrefs.blank_lines_before_method= 2; - String input = getCompilationUnit("Formatter", "", "test214283", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test214283", "C_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/212867 - [formatter]: Remove blank lines after '{' and before '}' - */ -public void testBug212867a() throws JavaModelException { - this.formatterPrefs.blank_lines_at_beginning_of_code_block = 2; - this.formatterPrefs.blank_lines_at_end_of_code_block = 0; - formatSourceInWorkspace("test212867", "in.java", "A_out.java"); -} -/** - * https://bugs.eclipse.org/212867 - [formatter]: Remove blank lines after '{' and before '}' - */ -public void testBug212867b() throws JavaModelException { - this.formatterPrefs.blank_lines_at_beginning_of_code_block = 0; - this.formatterPrefs.blank_lines_at_end_of_code_block = 2; - formatSourceInWorkspace("test212867", "in.java", "B_out.java"); -} -/** - * https://bugs.eclipse.org/212867 - [formatter]: Remove blank lines after '{' and before '}' - */ -public void testBug212867c() throws JavaModelException { - this.formatterPrefs.blank_lines_at_beginning_of_code_block = 2; - this.formatterPrefs.blank_lines_at_end_of_code_block = 2; - formatSourceInWorkspace("test212867", "in.java", "C_out.java"); -} -/** - * https://bugs.eclipse.org/212867 - [formatter]: Remove blank lines after '{' and before '}' - */ -public void testBug212867d() throws JavaModelException { - this.formatterPrefs.blank_lines_at_beginning_of_code_block = ~0; - this.formatterPrefs.blank_lines_at_end_of_code_block = ~0; - formatSourceInWorkspace("test212867", "in.java", "D_out.java"); -} -/** - * https://bugs.eclipse.org/421492 - [formatter] Allow to add blank line(s) before a statement - */ -public void testBug421492a() throws JavaModelException { - this.formatterPrefs.blank_lines_before_code_block = 2; - this.formatterPrefs.blank_lines_after_code_block = 0; - formatSourceInWorkspace("test421492", "in.java", "A_out.java"); -} -/** - * https://bugs.eclipse.org/421492 - [formatter] Allow to add blank line(s) before a statement - */ -public void testBug421492b() throws JavaModelException { - this.formatterPrefs.blank_lines_before_code_block = 0; - this.formatterPrefs.blank_lines_after_code_block = 2; - formatSourceInWorkspace("test421492", "in.java", "B_out.java"); -} -/** - * https://bugs.eclipse.org/421492 - [formatter] Allow to add blank line(s) before a statement - */ -public void testBug421492c() throws JavaModelException { - this.formatterPrefs.blank_lines_before_code_block = 2; - this.formatterPrefs.blank_lines_after_code_block = 2; - formatSourceInWorkspace("test421492", "in.java", "C_out.java"); -} -/** - * https://bugs.eclipse.org/421492 - [formatter] Allow to add blank line(s) before a statement - */ -public void testBug421492d() throws JavaModelException { - this.formatterPrefs.blank_lines_before_code_block = ~0; - this.formatterPrefs.blank_lines_after_code_block = ~0; - formatSourceInWorkspace("test421492", "in.java", "D_out.java"); -} -/** - * https://bugs.eclipse.org/390720 - [formatter] Add setting for blank line between case blocks (after break) for switch statement - */ -public void testBug390720a() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_14); - this.formatterPrefs.blank_lines_between_statement_groups_in_switch = 2; - formatSourceInWorkspace("test390720", "in.java", "A_out.java"); -} -/** - * https://bugs.eclipse.org/390720 - [formatter] Add setting for blank line between case blocks (after break) for switch statement - */ -public void testBug390720b() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_14); - this.formatterPrefs.blank_lines_between_statement_groups_in_switch = ~0; - formatSourceInWorkspace("test390720", "in.java", "B_out.java"); -} -/** - * https://bugs.eclipse.org/549436 - [13] Formatter support for JEP 355 Text Block - */ -public void testBug549436a() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_15); - setPageWidth80(); - this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE; - this.formatterPrefs.use_tabs_only_for_leading_indentations = false; - this.formatterPrefs.indent_empty_lines = false; - this.formatterPrefs.text_block_indentation = Alignment.M_INDENT_PRESERVE; - this.formatterPrefs.continuation_indentation = 2; - formatSourceInWorkspace("test549436", "in.java", "A_out.java"); -} -/** - * https://bugs.eclipse.org/549436 - [13] Formatter support for JEP 355 Text Block - */ -public void testBug549436b() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_15); - setPageWidth80(); - this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE; - this.formatterPrefs.use_tabs_only_for_leading_indentations = false; - this.formatterPrefs.indent_empty_lines = false; - this.formatterPrefs.text_block_indentation = Alignment.M_INDENT_BY_ONE; - this.formatterPrefs.continuation_indentation = 2; - formatSourceInWorkspace("test549436", "in.java", "B_out.java"); -} -/** - * https://bugs.eclipse.org/549436 - [13] Formatter support for JEP 355 Text Block - */ -public void testBug549436c() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_15); - setPageWidth80(); - this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE; - this.formatterPrefs.use_tabs_only_for_leading_indentations = false; - this.formatterPrefs.indent_empty_lines = false; - this.formatterPrefs.text_block_indentation = Alignment.M_INDENT_DEFAULT; - this.formatterPrefs.continuation_indentation = 2; - formatSourceInWorkspace("test549436", "in.java", "C_out.java"); -} -/** - * https://bugs.eclipse.org/549436 - [13] Formatter support for JEP 355 Text Block - */ -public void testBug549436d() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_15); - setPageWidth80(); - this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE; - this.formatterPrefs.use_tabs_only_for_leading_indentations = false; - this.formatterPrefs.indent_empty_lines = false; - this.formatterPrefs.text_block_indentation = Alignment.M_INDENT_DEFAULT; - this.formatterPrefs.continuation_indentation = 3; - formatSourceInWorkspace("test549436", "in.java", "D_out.java"); -} -/** - * https://bugs.eclipse.org/549436 - [13] Formatter support for JEP 355 Text Block - */ -public void testBug549436e() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_15); - setPageWidth80(); - this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE; - this.formatterPrefs.use_tabs_only_for_leading_indentations = false; - this.formatterPrefs.indent_empty_lines = false; - this.formatterPrefs.text_block_indentation = Alignment.M_INDENT_ON_COLUMN; - this.formatterPrefs.continuation_indentation = 2; - formatSourceInWorkspace("test549436", "in.java", "E_out.java"); -} -/** - * https://bugs.eclipse.org/549436 - [13] Formatter support for JEP 355 Text Block - */ -public void testBug549436f() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_15); - setPageWidth80(); - this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.TAB; - this.formatterPrefs.use_tabs_only_for_leading_indentations = false; - this.formatterPrefs.indent_empty_lines = false; - this.formatterPrefs.text_block_indentation = Alignment.M_INDENT_BY_ONE; - this.formatterPrefs.continuation_indentation = 2; - formatSourceInWorkspace("test549436", "in.java", "F_out.java"); -} -/** - * https://bugs.eclipse.org/549436 - [13] Formatter support for JEP 355 Text Block - */ -public void testBug549436g() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_15); - setPageWidth80(); - this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.TAB; - this.formatterPrefs.use_tabs_only_for_leading_indentations = false; - this.formatterPrefs.indent_empty_lines = true; - this.formatterPrefs.text_block_indentation = Alignment.M_INDENT_DEFAULT; - this.formatterPrefs.continuation_indentation = 2; - formatSourceInWorkspace("test549436", "in.java", "G_out.java"); -} -/** - * https://bugs.eclipse.org/549436 - [13] Formatter support for JEP 355 Text Block - */ -public void testBug549436h() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_15); - setPageWidth80(); - this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.TAB; - this.formatterPrefs.use_tabs_only_for_leading_indentations = true; - this.formatterPrefs.indent_empty_lines = false; - this.formatterPrefs.text_block_indentation = Alignment.M_INDENT_DEFAULT; - this.formatterPrefs.continuation_indentation = 3; - formatSourceInWorkspace("test549436", "in.java", "H_out.java"); -} -/** - * https://bugs.eclipse.org/549436 - [13] Formatter support for JEP 355 Text Block - */ -public void testBug549436i() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_15); - setPageWidth80(); - this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.TAB; - this.formatterPrefs.use_tabs_only_for_leading_indentations = true; - this.formatterPrefs.indent_empty_lines = true; - this.formatterPrefs.text_block_indentation = Alignment.M_INDENT_ON_COLUMN; - this.formatterPrefs.continuation_indentation = 2; - formatSourceInWorkspace("test549436", "in.java", "I_out.java"); -} -/** - * https://bugs.eclipse.org/549436 - [13] Formatter support for JEP 355 Text Block - */ -public void testBug549436j() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_15); - setPageWidth80(); - this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.MIXED; - this.formatterPrefs.use_tabs_only_for_leading_indentations = false; - this.formatterPrefs.indent_empty_lines = false; - this.formatterPrefs.text_block_indentation = Alignment.M_INDENT_ON_COLUMN; - this.formatterPrefs.continuation_indentation = 2; - formatSourceInWorkspace("test549436", "in.java", "J_out.java"); -} -/** - * https://bugs.eclipse.org/549436 - [13] Formatter support for JEP 355 Text Block - */ -public void testBug549436k() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_15); - setPageWidth80(); - this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.TAB; - this.formatterPrefs.use_tabs_only_for_leading_indentations = false; - this.formatterPrefs.indent_empty_lines = false; - this.formatterPrefs.text_block_indentation = Alignment.M_INDENT_ON_COLUMN; - this.formatterPrefs.continuation_indentation = 2; - formatSourceInWorkspace("test549436", "in.java", "K_out.java"); -} -/** - * https://bugs.eclipse.org/54627 - [formatter] Blank lines between Javadoc tags - */ -public void testBug54627a() throws JavaModelException { - this.formatterPrefs.comment_insert_empty_line_between_different_tags = true; - String input = - "public class Test {\n" + - " /**\n" + - " * Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.\n" + - " * @param a Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\n" + - " * @param b Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.\n" + - " * @param c Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n" + - " * @throws IOException Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium.\n" + - " * @throws SQLException Totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.\n" + - " * @return Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.\n" + - " */\n" + - " public String f(int a, int b, int c) throws IOException, SQLException {\n" + - " return \"\";\n" + - " }\n" + - "}"; - formatSource(input, - "public class Test {\n" + - " /**\n" + - " * Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\n" + - " * tempor incididunt ut labore et dolore magna aliqua. Neque porro quisquam est,\n" + - " * qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia\n" + - " * non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam\n" + - " * quaerat voluptatem.\n" + - " * \n" + - " * @param a Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris\n" + - " * nisi ut aliquip ex ea commodo consequat.\n" + - " * @param b Duis aute irure dolor in reprehenderit in voluptate velit esse\n" + - " * cillum dolore eu fugiat nulla pariatur.\n" + - " * @param c Excepteur sint occaecat cupidatat non proident, sunt in culpa qui\n" + - " * officia deserunt mollit anim id est laborum.\n" + - " * \n" + - " * @throws IOException Sed ut perspiciatis unde omnis iste natus error sit\n" + - " * voluptatem accusantium doloremque laudantium.\n" + - " * @throws SQLException Totam rem aperiam, eaque ipsa quae ab illo inventore\n" + - " * veritatis et quasi architecto beatae vitae dicta sunt\n" + - " * explicabo.\n" + - " * \n" + - " * @return Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut\n" + - " * fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem\n" + - " * sequi nesciunt.\n" + - " */\n" + - " public String f(int a, int b, int c) throws IOException, SQLException {\n" + - " return \"\";\n" + - " }\n" + - "}"); -} -/** - * https://bugs.eclipse.org/54627 - [formatter] Blank lines between Javadoc tags - */ -public void testBug54627b() throws JavaModelException { - this.formatterPrefs.comment_insert_empty_line_between_different_tags = true; - String input = - "public class Test {\n" + - " \n" + - " /**\n" + - " * Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.\n" + - " * @param a Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\n" + - " * @param b Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.\n" + - " * @return Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.\n" + - " * @@org.example.transaction.interceptor.RuleBasedTransactionAttribute()\n" + - " * @@org.example.transaction.interceptor.RollbackRuleAttribute(Exception.class)\n" + - " * @@org.example.transaction.interceptor.NoRollbackRuleAttribute(\"ServletException\")\n" + - " */\n" + - " public String f(int a, int b, int c) {\n" + - " return \"\";\n" + - " }\n" + - "}"; - formatSource(input, - "public class Test {\n" + - "\n" + - " /**\n" + - " * Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\n" + - " * tempor incididunt ut labore et dolore magna aliqua. Neque porro quisquam est,\n" + - " * qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia\n" + - " * non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam\n" + - " * quaerat voluptatem.\n" + - " * \n" + - " * @param a Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris\n" + - " * nisi ut aliquip ex ea commodo consequat.\n" + - " * @param b Duis aute irure dolor in reprehenderit in voluptate velit esse\n" + - " * cillum dolore eu fugiat nulla pariatur.\n" + - " * \n" + - " * @return Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut\n" + - " * fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem\n" + - " * sequi nesciunt.\n" + - " * \n" + - " * @@org.example.transaction.interceptor.RuleBasedTransactionAttribute()\n" + - " * @@org.example.transaction.interceptor.RollbackRuleAttribute(Exception.class)\n" + - " * @@org.example.transaction.interceptor.NoRollbackRuleAttribute(\"ServletException\")\n" + - " */\n" + - " public String f(int a, int b, int c) {\n" + - " return \"\";\n" + - " }\n" + - "}"); -} -/** - * https://bugs.eclipse.org/547261 - [formatter] Separate option for space after not (!) operator - */ -public void testBug547261() throws JavaModelException { - this.formatterPrefs.insert_space_after_not_operator = true; - String input = "class C {boolean b=!a&&!(c||d)&&(f!=-5);}"; - formatSource(input, - "class C {\n" + - " boolean b = ! a && ! (c || d) && (f != -5);\n" + - "}"); -} -/** - * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support - */ -public void testBug553155a() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_16); - formatSourceInWorkspace("test553155", "in.java", "A_out.java"); -} -/** - * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support - */ -public void testBug553155b() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_16); - this.formatterPrefs.indent_body_declarations_compare_to_record_header = false; - formatSourceInWorkspace("test553155", "in.java", "B_out.java"); -} -/** - * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support - */ -public void testBug553155c() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_16); - this.formatterPrefs.brace_position_for_record_declaration = DefaultCodeFormatterConstants.NEXT_LINE; - formatSourceInWorkspace("test553155", "in.java", "C_out.java"); -} -/** - * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support - */ -public void testBug553155d() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_16); - this.formatterPrefs.brace_position_for_record_constructor = DefaultCodeFormatterConstants.NEXT_LINE; - formatSourceInWorkspace("test553155", "in.java", "D_out.java"); -} -/** - * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support - */ -public void testBug553155e() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_16); - this.formatterPrefs.parenthesis_positions_in_record_declaration = DefaultCodeFormatterConstants.SEPARATE_LINES; - formatSourceInWorkspace("test553155", "in.java", "E_out.java"); -} -/** - * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support - */ -public void testBug553155f() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_16); - this.formatterPrefs.insert_space_after_comma_in_record_components = false; - formatSourceInWorkspace("test553155", "in.java", "F_out.java"); -} -/** - * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support - */ -public void testBug553155g() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_16); - this.formatterPrefs.insert_space_after_opening_paren_in_record_declaration = true; - formatSourceInWorkspace("test553155", "in.java", "G_out.java"); -} -/** - * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support - */ -public void testBug553155h() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_16); - this.formatterPrefs.insert_space_before_closing_paren_in_record_declaration = true; - formatSourceInWorkspace("test553155", "in.java", "H_out.java"); -} -/** - * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support - */ -public void testBug553155i() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_16); - this.formatterPrefs.insert_space_before_comma_in_record_components = true; - formatSourceInWorkspace("test553155", "in.java", "I_out.java"); -} -/** - * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support - */ -public void testBug553155j() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_16); - this.formatterPrefs.insert_space_before_opening_brace_in_record_constructor = false; - formatSourceInWorkspace("test553155", "in.java", "J_out.java"); -} -/** - * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support - */ -public void testBug553155k() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_16); - this.formatterPrefs.insert_space_before_opening_brace_in_record_declaration = false; - formatSourceInWorkspace("test553155", "in.java", "K_out.java"); -} -/** - * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support - */ -public void testBug553155l() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_16); - this.formatterPrefs.insert_space_before_opening_paren_in_record_declaration = true; - formatSourceInWorkspace("test553155", "in.java", "L_out.java"); -} -/** - * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support - */ -public void testBug553155m() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_16); - this.formatterPrefs.alignment_for_record_components = Alignment.M_ONE_PER_LINE_SPLIT + + Alignment.M_FORCE; - formatSourceInWorkspace("test553155", "in.java", "M_out.java"); -} -/** - * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support - */ -public void testBug553155n() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_16); - this.formatterPrefs.alignment_for_superinterfaces_in_record_declaration = Alignment.M_ONE_PER_LINE_SPLIT + + Alignment.M_FORCE; - formatSourceInWorkspace("test553155", "in.java", "N_out.java"); -} -/** - * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support - */ -public void testBug553155o() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_16); - this.formatterPrefs.keep_record_constructor_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - String source = "record Range(int lo, int hi) {public Range {foo();}}"; - formatSource(source, - "record Range(int lo, int hi) {\n" + - " public Range { foo(); }\n" + - "}"); -} -/** - * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support - */ -public void testBug553155p() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_16); - this.formatterPrefs.keep_record_constructor_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - this.formatterPrefs.keep_record_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - String source = "record Range(int lo, int hi) {public Range {foo();}}"; - formatSource(source, - "record Range(int lo, int hi) { public Range { foo(); } }"); -} -/** - * https://bugs.eclipse.org/118641 - [formatter] Formatter does not break line on assert statement - * - * Check that assertions are not formatted without enabling the option. - */ -public void testBug118641a() throws JavaModelException { - this.formatterPrefs.alignment_for_assertion_message = Alignment.M_NO_ALIGNMENT; - - String input = - "public class Test {\n" + - "\n" + - " public void f(int a, int b) {\n" + - " assert childElement.getElementsByTagName(FIELD_NAME).getLength() == 1 : \"XML malformed. No attribute name! Please talk to your sysadmin.\";\n" + - " return;\n" + - " }\n" + - "}"; - formatSource(input, - "public class Test {\n" + - "\n" + - " public void f(int a, int b) {\n" + - " assert childElement.getElementsByTagName(FIELD_NAME)\n" + - " .getLength() == 1 : \"XML malformed. No attribute name! Please talk to your sysadmin.\";\n" + - " return;\n" + - " }\n" + - "}"); -} -/** - * https://bugs.eclipse.org/118641 - [formatter] Formatter does not break line on assert statement - * - * - * Check that an assertion is formatted when it exceeds the page width. - */ -public void testBug118641b() throws JavaModelException { - this.formatterPrefs.wrap_before_assertion_message_operator = true; - - String input = - "public class Test {\n" + - " \n" + - " public void f(int a, int b) {\n" + - " assert childElement.getElementsByTagName( FIELD_NAME ).getLength() == 1 : \"XML malformed. No attribute name! Please talk to your sysadmin.\";\n" + - " return;\n" + - " }\n" + - "}"; - formatSource(input, - "public class Test {\n" + - "\n" + - " public void f(int a, int b) {\n" + - " assert childElement.getElementsByTagName(FIELD_NAME).getLength() == 1\n" + - " : \"XML malformed. No attribute name! Please talk to your sysadmin.\";\n" + - " return;\n" + - " }\n" + - "}"); -} -/** - * https://bugs.eclipse.org/118641 - [formatter] Formatter does not break line on assert statement - * - * - * Check that an assertion can be broken after the colon separator. - */ -public void testBug118641c() throws JavaModelException { - this.formatterPrefs.wrap_before_assertion_message_operator = false; - - String input = - "public class Test {\n" + - " \n" + - " public void f(int a, int b) {\n" + - " assert childElement.getElementsByTagName( FIELD_NAME ).getLength() == 1 : \"XML malformed. No attribute name! Please talk to your sysadmin.\";\n" + - " return;\n" + - " }\n" + - "}"; - formatSource(input, - "public class Test {\n" + - "\n" + - " public void f(int a, int b) {\n" + - " assert childElement.getElementsByTagName(FIELD_NAME).getLength() == 1 :\n" + - " \"XML malformed. No attribute name! Please talk to your sysadmin.\";\n" + - " return;\n" + - " }\n" + - "}"); -} -/** - * https://bugs.eclipse.org/118641 - [formatter] Formatter does not break line on assert statement - * - * Check that assertion messages are formatted when the assertion expression exceeds the page width. - */ -public void testBug118641d() throws JavaModelException { - this.formatterPrefs.page_width = 65; - - String input = - "public class Test {\n" + - " \n" + - " public void f(int a, int b) {\n" + - " assert childElement.getElementsByTagName( FIELD_NAME ).getLength() == 1 : \"XML malformed. No attribute name! Please talk to your sysadmin.\";\n" + - " return;\n" + - " }\n" + - "}"; - formatSource(input, - "public class Test {\n" + - "\n" + - " public void f(int a, int b) {\n" + - " assert childElement.getElementsByTagName(FIELD_NAME)\n" + - " .getLength() == 1\n" + - " : \"XML malformed. No attribute name! Please talk to your sysadmin.\";\n" + - " return;\n" + - " }\n" + - "}"); -} -/** - * https://bugs.eclipse.org/118641 - [formatter] Formatter does not break line on assert statement - * - * Check that an assertion message is wrapped when forced to do so. - */ -public void testBug118641e() throws JavaModelException { - this.formatterPrefs.alignment_for_assertion_message = Alignment.M_COMPACT_SPLIT | Alignment.M_FORCE; - - String input = - "public class Test {\n" + - " \n" + - " public void f(int a, int b) {\n" + - " assert childElement.getElementsByTagName( FIELD_NAME ).getLength() == 1 : \"XML malformed. No attribute name!\";\n" + - " return;\n" + - " }\n" + - "}"; - formatSource(input, - "public class Test {\n" + - "\n" + - " public void f(int a, int b) {\n" + - " assert childElement.getElementsByTagName(FIELD_NAME).getLength() == 1\n" + - " : \"XML malformed. No attribute name!\";\n" + - " return;\n" + - " }\n" + - "}"); -} -/** - * https://bugs.eclipse.org/545078 - [formatter] Wrapping settings for annotations - */ -public void testBug545078a() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_5); - formatSourceInWorkspace("test545078", "in.java", "A_out.java"); -} -/** - * https://bugs.eclipse.org/545078 - [formatter] Wrapping settings for annotations - */ -public void testBug545078b() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_5); - this.formatterPrefs.alignment_for_annotations_on_package = Alignment.M_NO_ALIGNMENT; - this.formatterPrefs.insert_new_line_after_annotation_on_type = false; - formatSourceInWorkspace("test545078", "in.java", "B_out.java"); -} -/** - * https://bugs.eclipse.org/545078 - [formatter] Wrapping settings for annotations - */ -public void testBug545078c() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_5); - this.formatterPrefs.alignment_for_annotations_on_package = Alignment.M_COMPACT_SPLIT; - this.formatterPrefs.alignment_for_annotations_on_type = Alignment.M_NO_ALIGNMENT; - this.formatterPrefs.insert_new_line_after_annotation_on_method = false; - formatSourceInWorkspace("test545078", "in.java", "C_out.java"); -} -/** - * https://bugs.eclipse.org/545078 - [formatter] Wrapping settings for annotations - */ -public void testBug545078d() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_5); - this.formatterPrefs.alignment_for_annotations_on_package = Alignment.M_NEXT_PER_LINE_SPLIT; - this.formatterPrefs.alignment_for_annotations_on_type = Alignment.M_COMPACT_FIRST_BREAK_SPLIT; - this.formatterPrefs.alignment_for_annotations_on_method = Alignment.M_NO_ALIGNMENT; - this.formatterPrefs.insert_new_line_after_annotation_on_local_variable = false; - formatSourceInWorkspace("test545078", "in.java", "D_out.java"); -} -/** - * https://bugs.eclipse.org/545078 - [formatter] Wrapping settings for annotations - */ -public void testBug545078e() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_5); - this.formatterPrefs.page_width = 105; - this.formatterPrefs.alignment_for_annotations_on_method = Alignment.M_COMPACT_SPLIT; - this.formatterPrefs.alignment_for_annotations_on_local_variable = Alignment.M_NO_ALIGNMENT; - this.formatterPrefs.insert_new_line_after_annotation_on_field = false; - formatSourceInWorkspace("test545078", "in.java", "E_out.java"); -} -/** - * https://bugs.eclipse.org/545078 - [formatter] Wrapping settings for annotations - */ -public void testBug545078f() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_5); - this.formatterPrefs.page_width= 95; - this.formatterPrefs.alignment_for_annotations_on_local_variable = Alignment.M_COMPACT_SPLIT; - this.formatterPrefs.alignment_for_annotations_on_field = Alignment.M_NO_ALIGNMENT; - this.formatterPrefs.insert_new_line_after_annotation_on_parameter = true; - formatSourceInWorkspace("test545078", "in.java", "F_out.java"); -} -/** - * https://bugs.eclipse.org/545078 - [formatter] Wrapping settings for annotations - */ -public void testBug545078g() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_5); - this.formatterPrefs.alignment_for_annotations_on_field = Alignment.M_COMPACT_SPLIT; - this.formatterPrefs.alignment_for_annotations_on_parameter = Alignment.M_ONE_PER_LINE_SPLIT; - this.formatterPrefs.insert_new_line_after_type_annotation = true; - formatSourceInWorkspace("test545078", "in.java", "G_out.java"); -} -/** - * https://bugs.eclipse.org/545078 - [formatter] Wrapping settings for annotations - */ -public void testBug545078h() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_5); - this.formatterPrefs.page_width = 105; - this.formatterPrefs.alignment_for_annotations_on_parameter = Alignment.M_COMPACT_SPLIT; - this.formatterPrefs.alignment_for_type_annotations = Alignment.M_ONE_PER_LINE_SPLIT; - this.formatterPrefs.insert_new_line_after_annotation_on_package = false; - formatSourceInWorkspace("test545078", "in.java", "H_out.java"); -} -/** - * https://bugs.eclipse.org/545078 - [formatter] Wrapping settings for annotations - */ -public void testBug545078i() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_5); - this.formatterPrefs.page_width = 105; - this.formatterPrefs.alignment_for_type_annotations = Alignment.M_COMPACT_SPLIT; - this.formatterPrefs.alignment_for_annotations_on_enum_constant = Alignment.M_NO_ALIGNMENT; - this.formatterPrefs.insert_new_line_after_annotation_on_enum_constant = false; - formatSourceInWorkspace("test545078", "in.java", "I_out.java"); -} -/** - * https://bugs.eclipse.org/545078 - [formatter] Wrapping settings for annotations - */ -public void testBug545078j() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_1_5); - this.formatterPrefs.page_width = 80; - this.formatterPrefs.alignment_for_annotations_on_package = Alignment.M_COMPACT_SPLIT; - this.formatterPrefs.alignment_for_annotations_on_type = Alignment.M_COMPACT_SPLIT; - this.formatterPrefs.alignment_for_annotations_on_method = Alignment.M_COMPACT_SPLIT; - this.formatterPrefs.alignment_for_annotations_on_field = Alignment.M_COMPACT_SPLIT; - this.formatterPrefs.alignment_for_annotations_on_parameter = Alignment.M_COMPACT_SPLIT; - this.formatterPrefs.alignment_for_annotations_on_local_variable = Alignment.M_COMPACT_SPLIT; - this.formatterPrefs.alignment_for_type_annotations = Alignment.M_COMPACT_SPLIT; - this.formatterPrefs.alignment_for_annotations_on_enum_constant = Alignment.M_COMPACT_SPLIT; - formatSourceInWorkspace("test545078", "in.java", "J_out.java"); -} - -/** - * https://bugs.eclipse.org/222083 - [formatter] Formatting bug for GWT code - */ -public void testBug222083() { - String source = - "class C {\n" + - " private static native void redirect(String url)/*-{\n" + - " $wnd.location = url;\n" + - " }-*/;\n" + - "}"; - formatSource(source); -} - -/** - * Bug 567016 - [formatter] off/on tags: enable by default - */ -public void testBug567016() { - this.formatterPrefs.use_tags = false; - String source = - "public class X01 {\n" + - "\n" + - "/* @formatter:off */\n" + - "void foo( ) { \n" + - " // unformatted comment\n" + - "}\n" + - "/* @formatter:on */\n" + - "void bar( ) { \n" + - " // formatted comment\n" + - "}\n" + - "}\n"; - formatSource(source, - "public class X01 {\n" + - "\n" + - " /* @formatter:off */\n" + - " void foo() {\n" + - " // unformatted comment\n" + - " }\n" + - "\n" + - " /* @formatter:on */\n" + - " void bar() {\n" + - " // formatted comment\n" + - " }\n" + - "}\n" - ); -} - -/** - * https://bugs.eclipse.org/573949 - [17][switch pattern][formatter] JEP 406 changes - */ -public void testBug573949() { - setComplianceLevel(CompilerOptions.VERSION_21); - this.formatterOptions.put(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED); - String source = - "public class X {\n" + - " private static void foo(Object o) {\n" + - " switch (o) {\n" + - " case Integer t, String : System.out.println(\"Error should be flagged for Integer and String\");\n" + - " default : System.out.println(\"Object\");\n" + - " }\n" + - " }\n" + - "\n" + - "static void testTriangle(Shape s) {\n" + - " switch (s) {\n" + - " case Triangle t when t.calculateArea() > 100 ->\n" + - " System.out.println(\"Large triangle\");\n" + - " default ->\n" + - " System.out.println(\"A shape, possibly a small triangle\");\n" + - " }\n" + - "}\n" + - "}"; - formatSource(source, - "public class X {\n" + - " private static void foo(Object o) {\n" + - " switch (o) {\n" + - " case Integer t, String:\n" + - " System.out.println(\"Error should be flagged for Integer and String\");\n" + - " default:\n" + - " System.out.println(\"Object\");\n" + - " }\n" + - " }\n" + - "\n" + - " static void testTriangle(Shape s) {\n" + - " switch (s) {\n" + - " case Triangle t when t.calculateArea() > 100 -> System.out.println(\"Large triangle\");\n" + - " default -> System.out.println(\"A shape, possibly a small triangle\");\n" + - " }\n" + - " }\n" + - "}" - ); -} - -/** - * https://bugs.eclipse.org/576373 - [formatting] Add formatting setting for whitespace in permits clause - */ -public void testBug576373() { - setComplianceLevel(CompilerOptions.VERSION_17); - String source = - "public sealed class X permits Y, Z {\n" + - "}"; - formatSource(source); -} - -/** - * https://bugs.eclipse.org/577117 - [formatter] Wrong indentation for method invocation on multi-line expression - */ -public void testBug577117a() { - this.formatterPrefs.page_width = 55; - this.formatterPrefs.align_selector_in_method_invocation_on_expression_first_line = false; - String source = - "class Example {\n" + - " String foo() {\n" + - " return new StringBuilder(Arrays.asList(11111111, 22222222, 3333333, 44444444)).append(\"TextTextText\").append(11111111 + 2222222 + 33333333).toStrinig();\n" + - " }\n" + - "}"; - formatSource(source, - "class Example {\n" + - " String foo() {\n" + - " return new StringBuilder(Arrays.asList(\n" + - " 11111111, 22222222, 3333333, 44444444))\n" + - " .append(\"TextTextText\")\n" + - " .append(11111111 + 2222222\n" + - " + 33333333)\n" + - " .toStrinig();\n" + - " }\n" + - "}"); -} -/** - * https://bugs.eclipse.org/577117 - [formatter] Wrong indentation for method invocation on multi-line expression - */ -public void testBug577117b() { - this.formatterPrefs.page_width = 53; - String source = - "class Example {\n" + - " String foo() {\n" + - " return new StringBuilder(Arrays.asList(11111111, 22222222, 3333333, 444444)).append(\"TextTextText\").append(11111111 + 2222222 + 33333333).toStrinig();\n" + - " }\n" + - "}"; - formatSource(source, - "class Example {\n" + - " String foo() {\n" + - " return new StringBuilder(Arrays.asList(\n" + - " 11111111, 22222222, 3333333, 444444))\n" + - " .append(\"TextTextText\")\n" + - " .append(11111111 + 2222222\n" + - " + 33333333)\n" + - " .toStrinig();\n" + - " }\n" + - "}"); -} - -/** - * https://bugs.eclipse.org/578044 - [Formatter] Case statement in switch expression is not line wrapped - */ -public void testBug578044a() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_14); - this.formatterPrefs.page_width = 60; - String input = getCompilationUnit("Formatter", "", "test578044", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test578044", "A_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/578044 - [Formatter] Case statement in switch expression is not line wrapped - */ -public void testBug578044b() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_14); - this.formatterPrefs.page_width = 60; - this.formatterPrefs.alignment_for_switch_case_with_arrow = Alignment.M_COMPACT_SPLIT + Alignment.M_INDENT_DEFAULT; - String input = getCompilationUnit("Formatter", "", "test578044", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test578044", "B_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/578044 - [Formatter] Case statement in switch expression is not line wrapped - */ -public void testBug578044c() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_14); - this.formatterPrefs.page_width = 60; - this.formatterPrefs.alignment_for_switch_case_with_arrow = Alignment.M_COMPACT_SPLIT + Alignment.M_INDENT_DEFAULT - + Alignment.M_FORCE; - this.formatterPrefs.wrap_before_switch_case_arrow_operator = true; - String input = getCompilationUnit("Formatter", "", "test578044", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test578044", "C_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/578044 - [Formatter] Case statement in switch expression is not line wrapped - */ -public void testBug578044d() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_14); - this.formatterPrefs.page_width = 60; - this.formatterPrefs.alignment_for_expressions_in_switch_case_with_arrow = Alignment.M_NEXT_PER_LINE_SPLIT + Alignment.M_INDENT_BY_ONE; - String input = getCompilationUnit("Formatter", "", "test578044", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test578044", "D_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/578044 - [Formatter] Case statement in switch expression is not line wrapped - */ -public void testBug578044e() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_14); - this.formatterPrefs.page_width = 60; - this.formatterPrefs.alignment_for_expressions_in_switch_case_with_colon = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_INDENT_ON_COLUMN; - String input = getCompilationUnit("Formatter", "", "test578044", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test578044", "E_out.java").getSource()); -} - -/** - * https://bugs.eclipse.org/578361 - [formatter] Keep braced code on one line: settings for new switch constructs - */ -public void testBug578361a() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_14); - this.formatterPrefs.page_width = 80; - this.formatterPrefs.keep_switch_case_with_arrow_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - String input = getCompilationUnit("Formatter", "", "test578361", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test578361", "A_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/578361 - [formatter] Keep braced code on one line: settings for new switch constructs - */ -public void testBug578361b() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_14); - this.formatterPrefs.page_width = 80; - this.formatterPrefs.keep_switch_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - String input = getCompilationUnit("Formatter", "", "test578361", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test578361", "B_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/578361 - [formatter] Keep braced code on one line: settings for new switch constructs - */ -public void testBug578361c() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_14); - this.formatterPrefs.keep_switch_case_with_arrow_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - this.formatterPrefs.keep_switch_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - String input = getCompilationUnit("Formatter", "", "test578361", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test578361", "C_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/578361 - [formatter] Keep braced code on one line: settings for new switch constructs - */ -public void testBug578361d() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_14); - this.formatterPrefs.keep_switch_case_with_arrow_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM; - this.formatterPrefs.keep_switch_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM; - String input = getCompilationUnit("Formatter", "", "test578361", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test578361", "D_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/578361 - [formatter] Keep braced code on one line: settings for new switch constructs - */ -public void testBug578361e() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_14); - this.formatterPrefs.page_width = 55; - this.formatterPrefs.keep_switch_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - this.formatterPrefs.keep_switch_case_with_arrow_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - this.formatterPrefs.alignment_for_switch_case_with_arrow = Alignment.M_COMPACT_SPLIT + Alignment.M_INDENT_BY_ONE; - String input = getCompilationUnit("Formatter", "", "test578361", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test578361", "E_out.java").getSource()); -} -/** - * https://bugs.eclipse.org/578361 - [formatter] Keep braced code on one line: settings for new switch constructs - */ -public void testBug578361f() throws JavaModelException { - setComplianceLevel(CompilerOptions.VERSION_14); - this.formatterPrefs.page_width = 55; - this.formatterPrefs.keep_switch_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - this.formatterPrefs.keep_switch_case_with_arrow_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; - this.formatterPrefs.alignment_for_switch_case_with_arrow = Alignment.M_NO_ALIGNMENT; - String input = getCompilationUnit("Formatter", "", "test578361", "in.java").getSource(); - formatSource(input, getCompilationUnit("Formatter", "", "test578361", "F_out.java").getSource()); -} -/** - * https://github.com/eclipse-jdt/eclipse.jdt.core/issues/264 - [19] Formatter support for JEP 405: Record Patterns - */ -public void testIssue264a() { - setComplianceLevel(CompilerOptions.VERSION_21); - this.formatterOptions.put(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED); - String source = - "public class X{int baz(Bar bar){return switch(bar){\n" + - " case Bar(Foo(var a,var b),Foo(var c,var d))->a+b+c+d;\n" + - "};}}"; - formatSource(source, - "public class X {\n" + - " int baz(Bar bar) {\n" + - " return switch (bar) {\n" + - " case Bar(Foo(var a, var b), Foo(var c, var d)) -> a + b + c + d;\n" + - " };\n" + - " }\n" + - "}"); -} -/** - * https://github.com/eclipse-jdt/eclipse.jdt.core/issues/264 - [19] Formatter support for JEP 405: Record Patterns - */ -public void testIssue264b() { - setComplianceLevel(CompilerOptions.VERSION_21); - this.formatterOptions.put(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED); - this.formatterPrefs.insert_space_before_comma_in_record_components = false; - this.formatterPrefs.insert_space_after_comma_in_record_components = false; - this.formatterPrefs.insert_space_before_opening_paren_in_record_declaration = true; - this.formatterPrefs.insert_space_after_opening_paren_in_record_declaration = true; - this.formatterPrefs.insert_space_before_closing_paren_in_record_declaration = true; - String source = - "public class X{int baz(Bar bar){return switch(bar){\n" + - " case Bar(Foo(var a,var b),Foo(var c,var d))->a+b+c+d;\n" + - "};}}"; - formatSource(source, - "public class X {\n" + - " int baz(Bar bar) {\n" + - " return switch (bar) {\n" + - " case Bar ( Foo ( var a,var b ),Foo ( var c,var d ) ) -> a + b + c + d;\n" + - " };\n" + - " }\n" + - "}"); -} -/** - * https://bugs.eclipse.org/564052 - [15] JEP 360 - Sealed Types -Formatter Support - */ -public void testBug564052() { - setComplianceLevel(CompilerOptions.VERSION_17); - this.formatterPrefs.alignment_for_permitted_types_in_type_declaration = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; - String source = - "sealed class Example permits C1, C2, C3 {}"; - formatSource(source, - "sealed class Example\n" + - " permits\n" + - " C1,\n" + - " C2,\n" + - " C3 {\n" + - "}"); -} - -/** - * https://github.com/eclipse-jdt/eclipse.jdt/issues/59 - Formatter support for guard expressions - */ -public void testGH59() { - setComplianceLevel(CompilerOptions.VERSION_21); - - String source = - """ - public class JunkClass { - Object myObj; - - void foo() { - when(myObj); - foo(myObj); - foo(myObj); - } - - void foo( Object stuff ) {} - void when( Object methodCall ) {} - } - """; - formatSource(source, - """ - public class JunkClass { - Object myObj; - - void foo() { - when(myObj); - foo(myObj); - foo(myObj); - } - - void foo(Object stuff) { - } - - void when(Object methodCall) { - } - } - """); -} - -} +/******************************************************************************* + * Copyright (c) 2000, 2022 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + * Brock Janiczak - Contribution for bug 150741 + * Ray V. (voidstar@gmail.com) - Contribution for bug 282988 + * Mateusz Matela - [formatter] Formatter does not format Java code correctly, especially when max line width is set - https://bugs.eclipse.org/303519 + *******************************************************************************/ +package org.eclipse.jdt.core.tests.formatter; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Map; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import junit.framework.Test; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceDescription; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Path; +import org.eclipse.jdt.core.ICompilationUnit; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.core.ToolFactory; +import org.eclipse.jdt.core.compiler.CharOperation; +import org.eclipse.jdt.core.dom.ASTNode; +import org.eclipse.jdt.core.formatter.CodeFormatter; +import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; +import org.eclipse.jdt.core.formatter.IndentManipulation; +import org.eclipse.jdt.core.tests.model.AbstractJavaModelTests; +import org.eclipse.jdt.core.tests.util.Util; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; +import org.eclipse.jdt.internal.formatter.DefaultCodeFormatter; +import org.eclipse.jdt.internal.formatter.DefaultCodeFormatterOptions; +import org.eclipse.jdt.internal.formatter.DefaultCodeFormatterOptions.Alignment; +import org.eclipse.jface.text.IRegion; +import org.eclipse.jface.text.Region; +import org.eclipse.text.edits.TextEdit; + +@SuppressWarnings({"rawtypes", "unchecked"}) +public class FormatterRegressionTests extends AbstractJavaModelTests { + + protected static IJavaProject JAVA_PROJECT; + + public static final int UNKNOWN_KIND = 0; + public static final String IN = "_in"; + public static final String OUT = "_out"; + public static final boolean DEBUG = false; + static final String LINE_SEPARATOR = System.getProperty("line.separator"); + private long time; + + DefaultCodeFormatterOptions formatterPrefs; + Map formatterOptions; + + static { +// TESTS_NUMBERS = new int[] { 783 }; +// TESTS_RANGE = new int[] { 734, -1 }; +// TESTS_NAMES = new String[] {"testBug432593"}; + } + public static Test suite() { + return buildModelTestSuite(FormatterRegressionTests.class); + } + + public FormatterRegressionTests(String name) { + super(name); + } + + /** + * Helper method for tests that require a certain compiler compliance level. + * @param level use one of the {@code CompilerOptions.VERSION_***} constants + */ + protected void setComplianceLevel(String level) { + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, level); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, level); + this.formatterOptions.put(CompilerOptions.OPTION_Source, level); + } + + /* + * helper function for tests that are compatible with earlier page width + */ + protected void setPageWidth80() { + this.formatterPrefs.page_width = 80; + } + + /* + * helper function for tests that are compatible with earlier page width + */ + protected void setPageWidth80(DefaultCodeFormatterOptions preferences) { + preferences.page_width = 80; + } + + /* + * helper function for tests that are compatible with earlier page width + */ + private void setFormatterOptions80() { + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, Integer.toString(80)); + } + + /* + * helper function for tests that are compatible with earlier Javadoc formatting rules + */ + protected void useOldJavadocTagsFormatting() { + this.formatterPrefs.comment_insert_new_line_for_parameter = true; + this.formatterPrefs.comment_align_tags_descriptions_grouped = false; + this.formatterPrefs.comment_indent_root_tags = true; + this.formatterPrefs.comment_indent_parameter_description = true; + } + + /** + * Helper function for tests that are expect comment width counted from the + * beginning of the line, not from comment's starting position. + */ + protected void useOldCommentWidthCounting() { + this.formatterPrefs.comment_count_line_length_from_starting_position = false; + } + + /** + * Helper function for old tests that are expect comment line comments + * on first column to be formatted. + */ + protected void setFormatLineCommentOnFirstColumn() { + this.formatterPrefs.comment_format_line_comment_starting_on_first_column = true; + } + + private String getResource(String packageName, String resourceName) { + IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + IResource resource = workspaceRoot.findMember(new Path("/Formatter/" + packageName + "/" + resourceName)); + assertNotNull("No resource found", resource); + return resource.getLocation().toOSString(); + } + + private String getZipEntryContents(String fileName, String zipEntryName) { + ZipFile zipFile = null; + BufferedInputStream inputStream = null; + try { + zipFile = new ZipFile(fileName); + ZipEntry zipEntry = zipFile.getEntry(zipEntryName); + inputStream = new BufferedInputStream(zipFile.getInputStream(zipEntry)); + return new String(org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsCharArray(inputStream, null)); + } catch (IOException e) { + } finally { + try { + if (inputStream != null) { + inputStream.close(); + } + if (zipFile != null) { + zipFile.close(); + } + } catch (IOException e1) { + // Do nothing + } + } + return null; + } + + /* + public String getSourceWorkspacePath() { + return getPluginDirectoryPath() + java.io.File.separator + "workspace"; + } + */ + + String runFormatter(CodeFormatter codeFormatter, String source, int kind, int indentationLevel, int offset, int length, String lineSeparator, boolean repeat) { +// long time = System.currentTimeMillis(); + TextEdit edit = codeFormatter.format(kind, source, offset, length, indentationLevel, lineSeparator);//$NON-NLS-1$ +// System.out.println((System.currentTimeMillis() - time) + " ms"); + if (edit == null) return null; +// System.out.println(edit.getChildrenSize() + " edits"); + String result = org.eclipse.jdt.internal.core.util.Util.editedString(source, edit); + + if (repeat && length == source.length()) { +// time = System.currentTimeMillis(); + edit = codeFormatter.format(kind, result, 0, result.length(), indentationLevel, lineSeparator);//$NON-NLS-1$ +// System.out.println((System.currentTimeMillis() - time) + " ms"); + if (edit == null) return null; +// assertEquals("Should not have edits", 0, edit.getChildren().length); + final String result2 = org.eclipse.jdt.internal.core.util.Util.editedString(result, edit); + if (!result.equals(result2)) { + assertSourceEquals("Second formatting is different from first one!", Util.convertToIndependantLineDelimiter(result), Util.convertToIndependantLineDelimiter(result2)); + } + } + return result; + } + + String runFormatter(CodeFormatter codeFormatter, String source, int kind, int indentationLevel, IRegion[] regions, String lineSeparator) { +// long time = System.currentTimeMillis(); + TextEdit edit = codeFormatter.format(kind, source, regions, indentationLevel, lineSeparator);//$NON-NLS-1$ +// System.out.println((System.currentTimeMillis() - time) + " ms"); + if (edit == null) return null; + + return org.eclipse.jdt.internal.core.util.Util.editedString(source, edit); + } + + /** + * Init formatter preferences with Eclipse default settings. + */ + @Override + protected void setUp() throws Exception { + super.setUp(); + this.formatterPrefs = DefaultCodeFormatterOptions.getEclipseDefaultSettings(); + if (JAVA_PROJECT != null) { + this.formatterOptions = JAVA_PROJECT.getOptions(true); + } + } + + /** + * Create project and set the jar placeholder. + */ + @Override + public void setUpSuite() throws Exception { + // ensure autobuilding is turned off + IWorkspaceDescription description = getWorkspace().getDescription(); + if (description.isAutoBuilding()) { + description.setAutoBuilding(false); + getWorkspace().setDescription(description); + } + + if (JAVA_PROJECT == null) { + JAVA_PROJECT = setUpJavaProject("Formatter"); //$NON-NLS-1$ + } + + if (DEBUG) { + this.time = System.currentTimeMillis(); + } + } + + /** + * Reset the jar placeholder and delete project. + */ + @Override + public void tearDownSuite() throws Exception { + deleteProject(JAVA_PROJECT); //$NON-NLS-1$ + JAVA_PROJECT = null; + if (DEBUG) { + System.out.println("Time spent = " + (System.currentTimeMillis() - this.time));//$NON-NLS-1$ + } + super.tearDownSuite(); + } + + private String getIn(String compilationUnitName) { + assertNotNull(compilationUnitName); + int dotIndex = compilationUnitName.indexOf('.'); + assertTrue(dotIndex != -1); + return compilationUnitName.substring(0, dotIndex) + IN + compilationUnitName.substring(dotIndex); + } + + private String getOut(String compilationUnitName) { + assertNotNull(compilationUnitName); + int dotIndex = compilationUnitName.indexOf('.'); + assertTrue(dotIndex != -1); + return compilationUnitName.substring(0, dotIndex) + OUT + compilationUnitName.substring(dotIndex); + } + + void assertLineEquals(String actualContents, String originalSource, String expectedContents, boolean checkNull) { + if (actualContents == null) { + assertTrue("actualContents is null", checkNull); + assertEquals(expectedContents, originalSource); + return; + } + assertSourceEquals("Different number of length", Util.convertToIndependantLineDelimiter(expectedContents), actualContents); + } + + void assertLineEquals(String actualContents, String originalSource, String expectedContents) { + String outputSource = expectedContents == null ? originalSource : expectedContents; + assertLineEquals(actualContents, originalSource, outputSource, false /* do not check null */); + } + + DefaultCodeFormatter codeFormatter() { + if (this.formatterOptions == null) { + this.formatterOptions = JAVA_PROJECT.getOptions(true); + } + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(this.formatterPrefs, this.formatterOptions); + return codeFormatter; + } + + void formatSource(String source) { + // expect unchanged source after formatting + formatSource(source, source); + } + + void formatSource(String source, String formattedOutput) { + formatSource(source, formattedOutput, CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS, 0, true /*repeat formatting twice*/); + } + + void formatSource(String source, String formattedOutput, int kind) { + formatSource(source, formattedOutput, kind, 0, true /*repeat formatting twice*/); + } + + void formatSource(String source, String formattedOutput, boolean repeat) { + formatSource(source, formattedOutput, CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS, 0, repeat); + } + + void formatSource(String source, String formattedOutput, int kind, int indentationLevel, boolean repeat) { + int regionStart = source.indexOf("[#"); + if (regionStart != -1) { + ArrayList regions = new ArrayList<>(); + int start = 0; + int delta = 0; + StringBuilder buffer = new StringBuilder(); + while (regionStart != -1) { + buffer.append(source.substring(start, regionStart)); + int regionEnd = source.indexOf("#]", regionStart+2); + buffer.append(source.substring(regionStart+2, regionEnd)); + regions.add(new Region(regionStart-delta, regionEnd-(regionStart+2))); + delta += 4; + start = regionEnd + 2; + regionStart = source.indexOf("[#", start); + } + buffer.append(source.substring(start, source.length())); + String newSource = buffer.toString(); + String result; + if (regions.size() == 1) { + // Use offset and length until bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=233967 is fixed + result = runFormatter(codeFormatter(), newSource, kind, indentationLevel, regions.get(0).getOffset(), regions.get(0).getLength(), LINE_SEPARATOR, repeat); + } else { + IRegion[] regionsArray = regions.toArray(new IRegion[regions.size()]); + result = runFormatter(codeFormatter(), newSource, kind, indentationLevel, regionsArray, LINE_SEPARATOR); + } + assertLineEquals(result, newSource, formattedOutput); + } else { + formatSource(source, formattedOutput, kind, indentationLevel, 0, -1, null, repeat); + } + } + + void formatSource(String source, String formattedOutput, int kind, int indentationLevel, int offset, int length, String lineSeparator, boolean repeat) { + DefaultCodeFormatter codeFormatter = codeFormatter(); + String result; + if (length == -1) { + result = runFormatter(codeFormatter, source, kind, indentationLevel, offset, source.length(), lineSeparator, repeat); + } else { + result = runFormatter(codeFormatter, source, kind, indentationLevel, offset, length, lineSeparator, repeat); + } + if (lineSeparator == null) { + assertLineEquals(result, source, formattedOutput); + } else { + // Do not convert line delimiter while comparing result when a specific one is specified + assertNotNull("Error(s) occured while formatting", result); + String outputSource = formattedOutput == null ? source : formattedOutput; + assertSourceEquals("Different number of length", outputSource, result, false/*do not convert line delimiter*/); + } + } + + void formatSourceInWorkspace(String packageName, String inputCuName, String outputCuName) throws JavaModelException { + String input = getCompilationUnit("Formatter", "", packageName, inputCuName).getSource(); + formatSource(input, getCompilationUnit("Formatter", "", packageName, outputCuName).getSource()); + } + + + private void runTest(String packageName, String compilationUnitName) { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, packageName, compilationUnitName, CodeFormatter.K_COMPILATION_UNIT, 0); + } + + private void runTest(CodeFormatter codeFormatter, String packageName, String compilationUnitName) { + runTest(codeFormatter, packageName, compilationUnitName, CodeFormatter.K_COMPILATION_UNIT, 0); + } + + private void runTest(String packageName, String compilationUnitName, int kind) { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, packageName, compilationUnitName, kind, 0); + } + + private void runTest(CodeFormatter codeFormatter, String packageName, String compilationUnitName, int kind) { + runTest(codeFormatter, packageName, compilationUnitName, kind, 0, false, 0, -1); + } + + private void runTest(CodeFormatter codeFormatter, String packageName, String compilationUnitName, int kind, boolean checkNull) { + runTest(codeFormatter, packageName, compilationUnitName, kind, 0, checkNull, 0, -1); + } + + private void runTest(CodeFormatter codeFormatter, String packageName, String compilationUnitName, int kind, int indentationLevel) { + runTest(codeFormatter, packageName, compilationUnitName, kind, indentationLevel, false, 0, -1); + } + private void runTest(CodeFormatter codeFormatter, String packageName, String compilationUnitName, int kind, int indentationLevel, boolean checkNull, int offset, int length) { + runTest(codeFormatter, packageName, compilationUnitName, kind, indentationLevel, checkNull, offset, length, null); + } + + private void runTest(String input, String output, CodeFormatter codeFormatter, int kind, int indentationLevel, boolean checkNull, int offset, int length, String lineSeparator) { + String result; + if (length == -1) { + result = runFormatter(codeFormatter, input, kind, indentationLevel, offset, input.length(), lineSeparator, true); + } else { + result = runFormatter(codeFormatter, input, kind, indentationLevel, offset, length, lineSeparator, true); + } + assertLineEquals(result, input, output, checkNull); + } + + private void runTest(String source, String expectedResult, CodeFormatter codeFormatter, int kind, int indentationLevel, boolean checkNull, int offset, int length) { + String result; + if (length == -1) { + result = runFormatter(codeFormatter, source, kind, indentationLevel, offset, source.length(), null, true); + } else { + result = runFormatter(codeFormatter, source, kind, indentationLevel, offset, length, null, true); + } + assertLineEquals(result, source, expectedResult, checkNull); + } + + private void runTest(CodeFormatter codeFormatter, String packageName, String compilationUnitName, int kind, int indentationLevel, boolean checkNull, int offset, int length, String lineSeparator) { + try { + ICompilationUnit sourceUnit = getCompilationUnit("Formatter" , "", packageName, getIn(compilationUnitName)); //$NON-NLS-1$ //$NON-NLS-2$ + String source = sourceUnit.getSource(); + assertNotNull(source); + ICompilationUnit outputUnit = getCompilationUnit("Formatter" , "", packageName, getOut(compilationUnitName)); //$NON-NLS-1$ //$NON-NLS-2$ + assertNotNull(outputUnit); + String result; + if (length == -1) { + result = runFormatter(codeFormatter, source, kind, indentationLevel, offset, source.length(), lineSeparator, true); + } else { + result = runFormatter(codeFormatter, source, kind, indentationLevel, offset, length, lineSeparator, true); + } + assertLineEquals(result, source, outputUnit.getSource(), checkNull); + } catch (JavaModelException e) { + e.printStackTrace(); + assertTrue(false); + } + } + + private void runTest(CodeFormatter codeFormatter, String packageName, String compilationUnitName, int kind, int indentationLevel, boolean checkNull, IRegion[] regions, String lineSeparator) { + try { + ICompilationUnit sourceUnit = getCompilationUnit("Formatter" , "", packageName, getIn(compilationUnitName)); //$NON-NLS-1$ //$NON-NLS-2$ + String s = sourceUnit.getSource(); + assertNotNull(s); + ICompilationUnit outputUnit = getCompilationUnit("Formatter" , "", packageName, getOut(compilationUnitName)); //$NON-NLS-1$ //$NON-NLS-2$ + assertNotNull(outputUnit); + setPageWidth80(); + String result= runFormatter(codeFormatter, s, kind, indentationLevel, regions, lineSeparator); + assertLineEquals(result, s, outputUnit.getSource(), checkNull); + } catch (JavaModelException e) { + e.printStackTrace(); + assertTrue(false); + } + } + + String getSource(ASTNode astNode, char[] source) { + String result = new String(CharOperation.subarray(source, astNode.getStartPosition() + 1, astNode.getStartPosition() + astNode.getLength() - 1)); + if (result.endsWith("\\n")) { + return result.substring(0, result.length() - 2) + LINE_SEPARATOR; + } + return result; + } + + public void test001() { + runTest("test001", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + public void test002() { + runTest("test002", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test003() { + runTest("test003", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test004() { + runTest("test004", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + public void test005() { + runTest("test005", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test006() { + runTest("test006", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test007() { + runTest("test007", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test008() { + runTest("test008", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test009() { + runTest("test009", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test010() { + runTest("test010", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test011() { + runTest("test011", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test012() { + runTest("test012", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test013() { + runTest("test013", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test014() { + runTest("test014", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test015() { + runTest("test015", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test016() { + runTest("test016", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test017() { + runTest("test017", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test018() { + runTest("test018", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test019() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test019", "A_1.java");//$NON-NLS-1$ //$NON-NLS-2$ + + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test019", "A_2.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test020() { + runTest("test020", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test021() { + runTest("test021", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test022() { + runTest("test022", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test023() { + runTest("test023", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test024() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + setPageWidth80(preferences); + preferences.keep_simple_if_on_one_line = true; + preferences.keep_then_statement_on_same_line = true; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test024", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test025() { + runTest("test025", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test026() { + runTest("test026", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test026b() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.wrap_outer_expressions_when_nested = false; + setPageWidth80(preferences); + 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$ + } + + public void test028() { + runTest("test028", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test029() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.keep_simple_if_on_one_line = true; + preferences.keep_then_statement_on_same_line = true; + preferences.keep_guardian_clause_on_one_line = true; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.compact_else_if = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter,"test029", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test030() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.keep_simple_if_on_one_line = true; + preferences.keep_then_statement_on_same_line = true; + preferences.keep_guardian_clause_on_one_line = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test030", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test031() { + runTest("test031", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test032() { + runTest("test032", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test033() { + runTest("test033", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test034() { + runTest("test034", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test035() { + runTest("test035", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test036() { + runTest("test036", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test037() { + runTest("test037", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test038() { + runTest("test038", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test039() { + runTest("test039", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test040() { + runTest("test040", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test041() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test041", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test042() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.insert_space_before_opening_brace_in_block = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test042", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test043() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test043", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test044() { + runTest("test044", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test045() { + runTest("test045", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test046() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_after_assignment_operator = false; + preferences.insert_space_before_assignment_operator = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test046", "A.java", CodeFormatter.K_EXPRESSION);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test047() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_after_assignment_operator = true; + preferences.insert_space_before_assignment_operator = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test047", "A.java", CodeFormatter.K_STATEMENTS, 2);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test048() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_after_assignment_operator = true; + preferences.insert_space_before_assignment_operator = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test048", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test049() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_after_assignment_operator = true; + preferences.insert_space_before_assignment_operator = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test049", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test050() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_after_additive_operator = false; + preferences.insert_space_before_unary_operator = false; + preferences.insert_space_after_unary_operator = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test050", "A.java", CodeFormatter.K_EXPRESSION);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test051() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_after_assignment_operator = true; + preferences.insert_space_before_assignment_operator = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test051", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test052() { + runTest("test052", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test053() { + runTest("test053", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test054() { + runTest("test054", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test055() { + runTest("test055", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test056() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.keep_simple_if_on_one_line = true; + preferences.keep_then_statement_on_same_line = true; + preferences.keep_else_statement_on_same_line = true; + preferences.keep_guardian_clause_on_one_line = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test056", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test057() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + assertEquals(false, DefaultCodeFormatterConstants.getForceWrapping((String)options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER))); + assertEquals(DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.getWrappingStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER))); + assertEquals(DefaultCodeFormatterConstants.INDENT_DEFAULT, DefaultCodeFormatterConstants.getIndentStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER))); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.align_type_members_on_columns = true; + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test057", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test058() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + assertEquals(false, DefaultCodeFormatterConstants.getForceWrapping((String)options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER))); + assertEquals(DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.getWrappingStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER))); + assertEquals(DefaultCodeFormatterConstants.INDENT_DEFAULT, DefaultCodeFormatterConstants.getIndentStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER))); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.align_type_members_on_columns = true; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.number_of_empty_lines_to_preserve = 0; + preferences.blank_lines_between_import_groups = 0; + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test058", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test059() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.align_type_members_on_columns = false; + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test059", "Parser.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test060() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.align_type_members_on_columns = false; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.number_of_empty_lines_to_preserve = 0; + preferences.blank_lines_between_import_groups = 0; + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + //long time = System.currentTimeMillis(); + runTest(codeFormatter, "test060", "Parser.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test061() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.number_of_empty_lines_to_preserve = 0; + preferences.blank_lines_between_import_groups = 0; + preferences.align_type_members_on_columns = false; + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test061", "Parser.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test062() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_after_assignment_operator = true; + preferences.insert_space_before_assignment_operator = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test062", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test063() { + runTest("test063", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test064() { + runTest("test064", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // Line break inside an array initializer (line comment) + public void test065() { + runTest("test065", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test066() { + runTest("test066", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test067() { + runTest("test067", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 3181 + public void test068() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.number_of_empty_lines_to_preserve = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test068", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 3327 + public void test069() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.number_of_empty_lines_to_preserve = 0; + preferences.blank_lines_before_first_class_body_declaration = 1; + preferences.blank_lines_before_method = 1; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test069", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // 5691 + public void test070() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test070", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test071() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.indent_body_declarations_compare_to_type_header = false; + preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.align_type_members_on_columns = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test071", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 7224 + public void test072() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.number_of_empty_lines_to_preserve = 1; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test072", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 7439 + public void test073() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.number_of_empty_lines_to_preserve = 0; + preferences.keep_simple_if_on_one_line = true; + preferences.keep_then_statement_on_same_line = true; + preferences.keep_guardian_clause_on_one_line = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test073", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 12321 + public void test074() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.number_of_empty_lines_to_preserve = 0; + preferences.insert_new_line_before_catch_in_try_statement = true; + preferences.insert_new_line_before_else_in_if_statement = true; + preferences.insert_new_line_before_finally_in_try_statement = true; + preferences.insert_new_line_before_while_in_do_statement = true; + preferences.keep_simple_if_on_one_line = false; + preferences.keep_then_statement_on_same_line = false; + preferences.keep_else_statement_on_same_line = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test074", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 14659 + public void test075() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.page_width = 57; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test075", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 16231 + public void test076() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test076", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 16233 + public void test077() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test077", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 17349 + public void test078() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.brace_position_for_block = DefaultCodeFormatterConstants.NEXT_LINE; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test078", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 19811 + public void test079() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.number_of_empty_lines_to_preserve = 0; + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test079", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 19811 + public void test080() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.continuation_indentation = 2; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test080", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 19811 + public void test081() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test081", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 19999 + public void test082() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.number_of_empty_lines_to_preserve = 2; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test082", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 20721 + public void test083() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test083", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 21943 + public void test084() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.number_of_empty_lines_to_preserve = 0; + preferences.insert_space_before_opening_paren_in_if = false; + preferences.insert_space_before_opening_paren_in_for = false; + preferences.insert_space_before_opening_paren_in_while = false; + preferences.keep_simple_if_on_one_line = true; + preferences.keep_then_statement_on_same_line = true; + preferences.keep_guardian_clause_on_one_line = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test084", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 21943 + public void test085() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.number_of_empty_lines_to_preserve = 0; + preferences.insert_space_before_opening_paren_in_if = true; + preferences.insert_space_before_opening_paren_in_for = true; + preferences.insert_space_before_opening_paren_in_while = true; + preferences.keep_simple_if_on_one_line = true; + preferences.keep_then_statement_on_same_line = true; + preferences.keep_guardian_clause_on_one_line = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test085", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 22313 + public void test086() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_new_line_before_catch_in_try_statement = true; + preferences.insert_new_line_before_else_in_if_statement = true; + preferences.insert_new_line_before_finally_in_try_statement = true; + preferences.insert_new_line_before_while_in_do_statement = true; + preferences.brace_position_for_block = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.brace_position_for_method_declaration = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.insert_space_before_relational_operator = false; + preferences.insert_space_after_relational_operator = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test086", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 23144 + public void test087() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.keep_simple_if_on_one_line = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test087", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 23144 + public void test088() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.keep_simple_if_on_one_line = false; + preferences.keep_guardian_clause_on_one_line = false; + preferences.keep_then_statement_on_same_line = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test088", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 24200 + public void test089() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_after_opening_paren_in_parenthesized_expression = true; + preferences.insert_space_before_closing_paren_in_parenthesized_expression = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test089", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 24200 + public void test090() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_after_opening_bracket_in_array_reference = true; + preferences.insert_space_before_closing_bracket_in_array_reference = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test090", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 25559 + public void test091() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_after_assignment_operator = false; + preferences.insert_space_before_assignment_operator = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test091", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 25559 + public void test092() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_after_relational_operator = false; + preferences.insert_space_before_relational_operator = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test092", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 25559 + public void test093() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_after_closing_paren_in_cast = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test093", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 25559 + public void test094() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_after_assignment_operator = false; + preferences.insert_space_before_assignment_operator = false; + preferences.insert_space_after_comma_in_method_invocation_arguments = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test094", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 27196 + public void test095() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.brace_position_for_block = DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED; + preferences.indent_statements_compare_to_block = false; + preferences.indent_statements_compare_to_body = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test095", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 28098 + public void test096() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.join_lines_in_comments = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test096", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS + CodeFormatter.F_INCLUDE_COMMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 34897 + public void test097() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_after_opening_paren_in_method_invocation = true; + preferences.insert_space_before_closing_paren_in_method_invocation = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test097", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 35173 + public void test098() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.brace_position_for_anonymous_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.brace_position_for_method_declaration = DefaultCodeFormatterConstants.NEXT_LINE; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test098", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 35433 + public void test099() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_before_opening_paren_in_method_declaration = true; + preferences.insert_space_before_opening_paren_in_for = true; + preferences.insert_space_after_semicolon_in_for = false; + preferences.put_empty_statement_on_new_line = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test099", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test100() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_before_opening_brace_in_array_initializer = true; + preferences.insert_space_after_opening_brace_in_array_initializer = true; + preferences.insert_space_before_closing_brace_in_array_initializer = true; + preferences.number_of_empty_lines_to_preserve = 1; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test100", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 36832 + public void test101() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test101", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 37057 + public void test102() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.number_of_empty_lines_to_preserve = 1; + preferences.line_separator = "\n";//$NON-NLS-1$ + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test102", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 37106 + public void test103() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test103", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 37657 + public void test104() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_after_opening_paren_in_if = true; + preferences.insert_space_before_closing_paren_in_if = true; + preferences.brace_position_for_block = DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED; + preferences.insert_new_line_before_catch_in_try_statement = true; + preferences.insert_new_line_before_else_in_if_statement = true; + preferences.insert_new_line_before_finally_in_try_statement = true; + preferences.insert_new_line_before_while_in_do_statement = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test104", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 38151 + public void test105() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.brace_position_for_method_declaration = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test105", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 39603 + public void test106() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test106", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 39607 + public void test107() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.keep_then_statement_on_same_line = false; + preferences.keep_simple_if_on_one_line = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test107", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 40777 + public void test108() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test108", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test109() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.blank_lines_before_package = 2; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test109", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test110() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.blank_lines_before_package = 1; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test110", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test111() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.blank_lines_after_package = 1; + preferences.blank_lines_before_first_class_body_declaration = 1; + preferences.blank_lines_before_new_chunk = 1; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test111", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test112() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.blank_lines_after_package = 1; + preferences.blank_lines_before_first_class_body_declaration = 1; + preferences.blank_lines_before_new_chunk = 1; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test112", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test113() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test113", "A.java");//$NON-NLS-1$ //$NON-NLS-2 + } + + // bug 14659 + public void test114() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + assertEquals(false, DefaultCodeFormatterConstants.getForceWrapping((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION))); + assertEquals(DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.getWrappingStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION))); + assertEquals(DefaultCodeFormatterConstants.INDENT_ON_COLUMN, DefaultCodeFormatterConstants.getIndentStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION))); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.page_width = 57; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test114", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 14659 + public void test115() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.page_width = 57; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test115", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // bug 14659 + public void test116() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.page_width = 57; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test116", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // JDT/UI tests + public void test117() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test117", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // JDT/UI tests + public void test118() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test118", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // JDT/UI tests + public void test119() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test119", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // JDT/UI tests + public void test120() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test120", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // JDT/UI tests + public void test121() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test121", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // probing statements + public void test122() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test122", "A.java", CodeFormatter.K_UNKNOWN);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // probing compilation unit + public void test123() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test123", "A.java", CodeFormatter.K_UNKNOWN);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // probing class body declarations + public void test124() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.page_width = 57; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test124", "A.java", CodeFormatter.K_UNKNOWN);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // probing expression + public void test125() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_after_additive_operator = false; + preferences.insert_space_before_unary_operator = false; + preferences.insert_space_after_unary_operator = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test125", "A.java", CodeFormatter.K_UNKNOWN);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // probing unrecognized source + public void test126() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test126", "A.java", CodeFormatter.K_UNKNOWN, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // probing unrecognized source + public void test127() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test127", "A.java", CodeFormatter.K_UNKNOWN);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // probing unrecognized source + public void test128() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test128", "A.java", CodeFormatter.K_UNKNOWN, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test129() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test129", "A.java", CodeFormatter.K_STATEMENTS, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test130() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test130", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test131() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test131", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test132() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test132", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test133() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.blank_lines_between_import_groups = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test133", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test134() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test134", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test135() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test135", "A.java", CodeFormatter.K_STATEMENTS, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test136() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test136", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test137() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test137", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test138() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test138", "A.java", CodeFormatter.K_STATEMENTS, 2, true, 8, 37);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test139() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test139", "A.java", CodeFormatter.K_STATEMENTS, 0, true, 0, 5);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test140() { + setComplianceLevel(CompilerOptions.VERSION_14); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test140", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test141() { + setComplianceLevel(CompilerOptions.VERSION_14); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.indent_switchstatements_compare_to_cases = false; + preferences.indent_switchstatements_compare_to_switch = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test141", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test142() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test142", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, 1);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test143() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test143", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, 1);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test144() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test144", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test145() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test145", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test146() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test146", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test147() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_before_assignment_operator = false; + preferences.number_of_empty_lines_to_preserve = 1; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test147", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test148() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test148", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test149() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test149", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test150() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test150", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test151() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test151", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test152() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test152", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test153() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.align_type_members_on_columns = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test153", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test154() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test154", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test155() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getJavaConventionsSettings()); + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.tab_size = 4; + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test155", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + //https://bugs.eclipse.org/bugs/show_bug.cgi?id=44036 + public void test156() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getJavaConventionsSettings()); + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.tab_size = 4; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test156", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test157() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test157", "A.java", CodeFormatter.K_STATEMENTS, 0, true, 11, 7);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test158() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test158", "A.java", CodeFormatter.K_STATEMENTS, 0, true, 11, 8);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test159() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 1; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test159", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /* + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44481 + */ + public void test160() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.insert_new_line_before_catch_in_try_statement = false; + preferences.insert_new_line_before_else_in_if_statement = false; + preferences.insert_new_line_before_finally_in_try_statement = false; + preferences.insert_new_line_before_while_in_do_statement = false; + preferences.compact_else_if = true; + preferences.number_of_empty_lines_to_preserve = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test160", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /* + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44481 + */ + public void test161() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.insert_new_line_before_catch_in_try_statement = false; + preferences.insert_new_line_before_else_in_if_statement = false; + preferences.insert_new_line_before_finally_in_try_statement = false; + preferences.insert_new_line_before_while_in_do_statement = false; + preferences.compact_else_if = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test161", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /* + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44481 + */ + public void test162() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.insert_new_line_before_catch_in_try_statement = true; + preferences.insert_new_line_before_else_in_if_statement = true; + preferences.insert_new_line_before_finally_in_try_statement = true; + preferences.insert_new_line_before_while_in_do_statement = true; + preferences.compact_else_if = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test162", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /* + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44481 + */ + public void test163() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.insert_new_line_before_catch_in_try_statement = true; + preferences.insert_new_line_before_else_in_if_statement = true; + preferences.insert_new_line_before_finally_in_try_statement = true; + preferences.insert_new_line_before_while_in_do_statement = true; + preferences.compact_else_if = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test163", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44493 + */ + public void test164() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test164", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test165() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test165", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44546 + */ + public void test166() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test166", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44503 + */ + public void test167() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + 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.wrap_outer_expressions_when_nested = false; + 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 + */ + public void test169() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + 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.wrap_outer_expressions_when_nested = false; + 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 + */ + public void test170() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + 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.wrap_outer_expressions_when_nested = false; + 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 + */ + public void test171() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.brace_position_for_anonymous_type_declaration = DefaultCodeFormatterConstants.END_OF_LINE; + preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.END_OF_LINE; + preferences.brace_position_for_method_declaration = DefaultCodeFormatterConstants.END_OF_LINE; + preferences.brace_position_for_block = DefaultCodeFormatterConstants.END_OF_LINE; + preferences.brace_position_for_switch = DefaultCodeFormatterConstants.END_OF_LINE; + preferences.compact_else_if = false; + preferences.insert_new_line_before_catch_in_try_statement = true; + preferences.insert_new_line_before_else_in_if_statement = true; + preferences.insert_new_line_before_finally_in_try_statement = true; + preferences.insert_new_line_before_while_in_do_statement = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test171", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44576 + */ + public void test172() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.number_of_empty_lines_to_preserve = 0; + preferences.brace_position_for_anonymous_type_declaration = DefaultCodeFormatterConstants.END_OF_LINE; + preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.END_OF_LINE; + preferences.brace_position_for_method_declaration = DefaultCodeFormatterConstants.END_OF_LINE; + preferences.brace_position_for_block = DefaultCodeFormatterConstants.END_OF_LINE; + preferences.brace_position_for_switch = DefaultCodeFormatterConstants.END_OF_LINE; + preferences.compact_else_if = false; + preferences.insert_new_line_before_catch_in_try_statement = true; + preferences.insert_new_line_before_else_in_if_statement = true; + preferences.insert_new_line_before_finally_in_try_statement = true; + preferences.insert_new_line_before_while_in_do_statement = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test172", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44570 + */ + public void test173() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_code_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test173", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44570 + */ + public void test174() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_code_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test174", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44570 + */ + public void test175() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test175", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44570 + */ + public void test176() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test176", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44570 + */ + public void test177() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test177", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44570 + */ + public void test178() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test178", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44570 + */ + public void test179() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test179", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44570 + */ + public void test180() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test180", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44651 + */ + public void test181() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test181", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44651 + */ + public void test182() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.number_of_empty_lines_to_preserve = 1; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test182", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44653 + */ + public void test183() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.number_of_empty_lines_to_preserve = 1; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test183", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44653 + */ + public void test184() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test184", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44653 + */ + public void test185() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test185", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void _test186() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test186", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44839 + */ + public void test187() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.blank_lines_between_import_groups = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test187", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44839 + */ + public void test188() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test188", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44839 + */ + public void test189() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.align_selector_in_method_invocation_on_expression_first_line = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test189", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test190() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1"); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test190", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test191() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test191", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test192() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.number_of_empty_lines_to_preserve = 0; + preferences.align_type_members_on_columns = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test192", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test193() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test193", "A.java", CodeFormatter.K_STATEMENTS, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test194() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test194", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test195() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test195", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test196() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test196", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test197() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test197", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test198() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test198", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test199() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test199", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test201() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test201", "A.java", CodeFormatter.K_STATEMENTS, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test202() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test202", "A.java", CodeFormatter.K_STATEMENTS, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test203() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test203", "A.java", CodeFormatter.K_STATEMENTS, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test204() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test204", "A.java", CodeFormatter.K_STATEMENTS, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test205() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1");//$NON-NLS-1$ + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test205", "A.java", CodeFormatter.K_STATEMENTS, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test206() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test206", "A.java", CodeFormatter.K_STATEMENTS, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test207() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test207", "A.java", CodeFormatter.K_STATEMENTS, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test208() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test208", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test209() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1");//$NON-NLS-1$ + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test209", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test210() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1");//$NON-NLS-1$ + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test210", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test211() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1");//$NON-NLS-1$ + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test211", "A.java", CodeFormatter.K_COMPILATION_UNIT, 1);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test212() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test212", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test213() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test213", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test214() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test214", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test215() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test215", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test216() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test216", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test217() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test217", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test218() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test218", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, 1);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test219() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test219", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, 1);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test220() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test220", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, 1);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test221() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test221", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test222() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test222", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + public void test223() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test223", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test224() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test224", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test225() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test225", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test226() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test226", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test227() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test227", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test228() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test228", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test229() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test229", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test230() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test230", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test231() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test231", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test232() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test232", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test233() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test233", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, 1);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test234() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test234", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test235() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test235", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test236() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test236", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test237() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test237", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test238() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test238", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test239() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test239", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test240() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test240", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test242() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test242", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test244() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test244", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test245() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test245", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test246() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test246", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test247() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test247", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test248() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test248", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test249() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test249", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test250() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test250", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test251() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test251", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test252() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test252", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test253() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test253", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test254() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test254", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test255() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test255", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test256() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test256", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test257() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test257", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test258() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test258", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test259() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test259", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test260() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test260", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test261() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test261", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test262() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test262", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test263() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test263", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test264() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test264", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test265() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test265", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test266() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test266", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test267() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test267", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test268() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test268", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test269() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test269", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test270() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test270", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test271() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test271", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test272() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK_IN_CASE, DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test272", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test273() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK_IN_CASE, DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test273", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test274() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test274", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test275() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test275", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test276() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test276", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test277() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test277", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test278() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test278", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test279() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test279", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test280() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test280", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test281() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test281", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test282() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test282", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test283() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test283", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test284() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test284", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test285() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test285", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test286() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test286", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test287() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test287", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test288() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test288", "A.java", CodeFormatter.K_STATEMENTS, 1);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test289() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test289", "A.java", CodeFormatter.K_STATEMENTS, 1);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test290() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test290", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test291() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test291", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test292() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test292", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test293() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test293", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test294() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test294", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test295() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test295", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test296() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test296", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test297() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); + options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "100"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.number_of_empty_lines_to_preserve = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test297", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test298() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "80"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test298", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test299() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "80"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test299", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test300() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test300", "A.java", CodeFormatter.K_EXPRESSION, 2);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test301() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST, JavaCore.DO_NOT_INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test301", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test302() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.number_of_empty_lines_to_preserve = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test302", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test303() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.number_of_empty_lines_to_preserve = 0; + preferences.indent_switchstatements_compare_to_cases = true; + preferences.indent_switchstatements_compare_to_switch = true; + preferences.indent_breaks_compare_to_cases = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test303", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test304() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.indent_switchstatements_compare_to_cases = true; + preferences.indent_switchstatements_compare_to_switch = true; + preferences.indent_breaks_compare_to_cases = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test304", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test305() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.indent_switchstatements_compare_to_cases = false; + preferences.indent_switchstatements_compare_to_switch = true; + preferences.indent_breaks_compare_to_cases = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test305", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test306() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.indent_switchstatements_compare_to_cases = true; + preferences.indent_switchstatements_compare_to_switch = true; + preferences.indent_breaks_compare_to_cases = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test306", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test307() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.indent_switchstatements_compare_to_cases = true; + preferences.indent_switchstatements_compare_to_switch = true; + preferences.indent_breaks_compare_to_cases = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test307", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test308() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.indent_switchstatements_compare_to_cases = false; + preferences.indent_switchstatements_compare_to_switch = false; + preferences.indent_breaks_compare_to_cases = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test308", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test309() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.indent_switchstatements_compare_to_cases = false; + preferences.indent_switchstatements_compare_to_switch = false; + preferences.indent_breaks_compare_to_cases = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test309", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test310() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test310", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test311() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test311", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test312() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test312", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test313() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test313", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test314() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test314", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test315() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + String source = "public final void addDefinitelyAssignedVariables(Scope scope, int initStateIndex) {\n" + + "/*\n" + + " \n" + + "*/\n" + + "}"; + String expectedResult = "public final void addDefinitelyAssignedVariables(Scope scope,\r\n" + + " int initStateIndex) {\r\n" + + " /*\r\n" + + " \r\n" + + " */\r\n" + + "}"; + runTest(source, expectedResult, codeFormatter, CodeFormatter.K_CLASS_BODY_DECLARATIONS, 0, false, 0, -1); + } + + public void test316() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + String source = "public final void addDefinitelyAssignedVariables(Scope scope, int initStateIndex) {\r" + + "/*\r" + + " \r" + + "*/\r" + + "}"; + String expectedResult = "public final void addDefinitelyAssignedVariables(Scope scope,\r\n" + + " int initStateIndex) {\r\n" + + " /*\r\n" + + " \r\n" + + " */\r\n" + + "}"; + runTest(source, expectedResult, codeFormatter, CodeFormatter.K_CLASS_BODY_DECLARATIONS, 0, false, 0, -1); + } + + public void test317() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.line_separator = "\n"; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + String source = "public final void addDefinitelyAssignedVariables(Scope scope, int initStateIndex) {\r\n" + + "/*\r\n" + + " \r\n" + + "*/\r\n" + + "}"; + String expectedResult = "public final void addDefinitelyAssignedVariables(Scope scope,\n" + + " int initStateIndex) {\n" + + " /*\n" + + " \n" + + " */\n" + + "}"; + runTest(source, expectedResult, codeFormatter, CodeFormatter.K_CLASS_BODY_DECLARATIONS, 0, false, 0, -1); + } + + public void test318() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.line_separator = "\r"; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + String source = "public final void addDefinitelyAssignedVariables(Scope scope, int initStateIndex) {\r" + + "/*\r" + + " \r" + + "*/\r" + + "}"; + String expectedResult = "public final void addDefinitelyAssignedVariables(Scope scope,\r" + + " int initStateIndex) {\r" + + " /*\r" + + " \r" + + " */\r" + + "}"; + runTest(source, expectedResult, codeFormatter, CodeFormatter.K_CLASS_BODY_DECLARATIONS, 0, false, 0, -1); + } + + public void test319() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test319", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test320() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test320", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test321() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test321", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test322() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test322", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test323() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_code_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test323", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=45141 + */ + public void test324() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test324", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=45220 + */ + public void test325() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test325", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=45465 + */ + public void test326() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test326", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=45508 + */ + public void test327() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test327", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=22073 + */ + public void test328() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test328", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=29473 + */ + public void test329() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test329", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=27249 + */ + public void test330() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.keep_empty_array_initializer_on_one_line = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test330", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=23709 + */ + public void test331() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test331", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=23709 + */ + public void test332() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test332", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=45968 + */ + public void test333() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.number_of_empty_lines_to_preserve = 5; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test333", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=46058 + */ + public void test334() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.put_empty_statement_on_new_line = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test334", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=46033 + */ + public void test335() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test335", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=46023 + */ + public void test336() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.number_of_empty_lines_to_preserve = 0; + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test336", "A.java", CodeFormatter.K_STATEMENTS, 8);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=46150 + */ + public void test337() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.number_of_empty_lines_to_preserve = 0; + 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.wrap_outer_expressions_when_nested = false; + 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 + */ + public void test338() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test338", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=46686 + */ + public void test339() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test339", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=46686 + */ + public void test340() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test340", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=46689 + */ + public void test341() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_before_unary_operator = false; + preferences.insert_space_after_assignment_operator = false; + preferences.insert_space_after_additive_operator = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test341", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=46690 + */ + public void test342() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_after_comma_in_multiple_local_declarations = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test342", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=46690 + */ + public void test343() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_after_comma_in_multiple_field_declarations = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test343", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=46690 + */ + public void test344() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_after_comma_in_multiple_field_declarations = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test344", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=46690 + */ + public void test345() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_after_comma_in_multiple_local_declarations = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test345", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44493 + */ + public void test347() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + assertEquals(DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.getWrappingStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION))); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.blank_lines_before_method = 1; + preferences.blank_lines_before_first_class_body_declaration = 1; + preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test347", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44493 + */ + public void test348() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.blank_lines_before_method = 1; + preferences.blank_lines_before_first_class_body_declaration = 1; + preferences.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test348", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44493 + */ + public void test349() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getJavaConventionsSettings()); + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.tab_size = 4; + preferences.blank_lines_before_first_class_body_declaration = 1; + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test349", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44653 + */ + public void test350() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test350", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44765 + */ + public void test351() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test351", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44653 + */ + public void test352() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getJavaConventionsSettings()); + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.tab_size = 4; + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test352", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44642 + */ + public void test353() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test353", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47799 + */ + public void test354() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, DefaultCodeFormatterConstants.FALSE); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test354", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47799 + */ + public void test355() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, DefaultCodeFormatterConstants.TRUE); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test355", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47800 + */ + public void test356() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_MULTIPLICATIVE_OPERATOR, DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test356", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47801 + */ + public void test357() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_PREFIX_OPERATOR, JavaCore.INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test357", "A.java", CodeFormatter.K_EXPRESSION);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47801 + */ + public void test358() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_PREFIX_OPERATOR, JavaCore.DO_NOT_INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test358", "A.java", CodeFormatter.K_EXPRESSION);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47811 + */ + public void test359() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test359", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47811 + */ + public void test360() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "2"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test360", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47811 + */ + public void test361() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test361", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47802 + */ + public void test362() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.page_width = 57; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test362", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47800 + */ + public void test363() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test363", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47986 + */ + public void test364() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_after_comma_in_for_inits = false; + preferences.insert_space_after_comma_in_for_increments = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test364", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47986 + */ + public void test365() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_after_comma_in_for_inits = false; + preferences.insert_space_after_comma_in_for_increments = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test365", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47986 + */ + public void test366() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_after_comma_in_for_inits = true; + preferences.insert_space_before_comma_in_for_inits = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test366", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47986 + */ + public void test367() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_after_comma_in_for_inits = true; + preferences.insert_space_before_comma_in_for_inits = true; + preferences.insert_space_after_comma_in_multiple_local_declarations = false; + preferences.insert_space_before_comma_in_multiple_local_declarations = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test367", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47918 + */ + public void test368() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1"); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_METHOD, "0"); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); + runTest(codeFormatter, "test368", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47918 + */ + public void test369() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "0"); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_METHOD, "1"); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_FIRST_CLASS_BODY_DECLARATION, "1"); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); + runTest(codeFormatter, "test369", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47918 + */ + public void test370() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1"); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_METHOD, "1"); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_FIRST_CLASS_BODY_DECLARATION, "1"); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); + runTest(codeFormatter, "test370", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47918 + */ + public void test371() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1"); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_METHOD, "0"); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); + runTest(codeFormatter, "test371", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47918 + */ + public void test372() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1"); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_METHOD, "0"); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); + runTest(codeFormatter, "test372", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47918 + */ + public void test373() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "0"); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_METHOD, "1"); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_FIRST_CLASS_BODY_DECLARATION, "1"); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); + runTest(codeFormatter, "test373", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44813 + */ + public void test374() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER, "1"); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); + runTest(codeFormatter, "test374", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44813 + */ + public void test375() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER, "1"); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); + runTest(codeFormatter, "test375", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44813 + */ + public void test376() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER, "1"); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); + runTest(codeFormatter, "test376", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44813 + */ + public void test377() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER, "1"); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); + runTest(codeFormatter, "test377", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44813 + */ + public void test378() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER, DefaultCodeFormatterConstants.END_OF_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER, "1"); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); + runTest(codeFormatter, "test378", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47997 + */ + public void test379() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER, DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED); + options.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER, "1"); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); + runTest(codeFormatter, "test379", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47997 + */ + public void test380() { + Hashtable options = new Hashtable(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_FIRST_CLASS_BODY_DECLARATION, "1"); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); + options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "100"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.number_of_empty_lines_to_preserve = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test380", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47997 + */ + public void test381() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "0"); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_METHOD, "1"); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_FIRST_CLASS_BODY_DECLARATION, "0"); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); + runTest(codeFormatter, "test381", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48131 + */ + public void test382() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(new DefaultCodeFormatterOptions(options)); + runTest(codeFormatter, "test382", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48141 + */ + public void test383() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.tab_size = 4; + preferences.blank_lines_before_first_class_body_declaration = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test383", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48143 + */ + public void _test384() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION, + DefaultCodeFormatterConstants.createAlignmentValue(true, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.tab_size = 4; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test384", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48143 + */ + public void test385() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION, + DefaultCodeFormatterConstants.createAlignmentValue(true, DefaultCodeFormatterConstants.WRAP_NEXT_SHIFTED, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + assertEquals(DefaultCodeFormatterConstants.WRAP_NEXT_SHIFTED, DefaultCodeFormatterConstants.getWrappingStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION))); + assertTrue(DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE != DefaultCodeFormatterConstants.getWrappingStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION))); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.blank_lines_before_first_class_body_declaration = 0; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.tab_size = 4; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test385", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48143 + */ + public void test386() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION, + DefaultCodeFormatterConstants.createAlignmentValue(true, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.blank_lines_before_first_class_body_declaration = 0; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.tab_size = 4; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test386", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48143 + */ + public void _test387() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); +// options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "40"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.page_width = 40; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.tab_size = 4; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test387", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48167 + */ + public void test388() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.tab_size = 4; + preferences.brace_position_for_array_initializer = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.page_width = 40; + preferences.insert_new_line_after_opening_brace_in_array_initializer = true; + preferences.insert_new_line_before_closing_brace_in_array_initializer = true; + preferences.blank_lines_before_first_class_body_declaration = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test388", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48167 + */ + public void test389() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, + DefaultCodeFormatterConstants.createAlignmentValue(true, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.continuation_indentation_for_array_initializer = 1; + preferences.brace_position_for_array_initializer = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.page_width = 40; + preferences.insert_new_line_after_opening_brace_in_array_initializer = true; + preferences.insert_new_line_before_closing_brace_in_array_initializer = true; + preferences.blank_lines_before_first_class_body_declaration = 0; + preferences.tab_size = 4; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test389", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48167 + */ + public void test390() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT_FIRST_BREAK, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.continuation_indentation_for_array_initializer = 1; + preferences.brace_position_for_array_initializer = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.page_width = 40; + preferences.insert_new_line_after_opening_brace_in_array_initializer = true; + preferences.insert_new_line_before_closing_brace_in_array_initializer = true; + preferences.blank_lines_before_first_class_body_declaration = 0; + preferences.tab_size = 4; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test390", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48167 + */ + public void test391() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_BY_ONE)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.blank_lines_before_first_class_body_declaration = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.continuation_indentation_for_array_initializer = 3; + preferences.brace_position_for_array_initializer = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.page_width = 40; + preferences.insert_new_line_after_opening_brace_in_array_initializer = true; + preferences.insert_new_line_before_closing_brace_in_array_initializer = true; + preferences.tab_size = 4; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test391", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48167 + */ + public void test392() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_BY_ONE)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.blank_lines_before_first_class_body_declaration = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.continuation_indentation_for_array_initializer = 3; + preferences.brace_position_for_array_initializer = DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED; + preferences.page_width = 40; + preferences.insert_new_line_after_opening_brace_in_array_initializer = true; + preferences.insert_new_line_before_closing_brace_in_array_initializer = true; + preferences.tab_size = 4; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test392", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48167 + */ + public void test393() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_size = 4; + preferences.blank_lines_before_first_class_body_declaration = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.continuation_indentation_for_array_initializer = 1; + preferences.brace_position_for_array_initializer = DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED; + preferences.page_width = 40; + preferences.insert_new_line_after_opening_brace_in_array_initializer = true; + preferences.insert_new_line_before_closing_brace_in_array_initializer = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test393", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=48404 + */ + public void test394() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.number_of_empty_lines_to_preserve = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test394", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49318 + */ + public void test395() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.insert_space_before_opening_paren_in_method_declaration = true; + preferences.number_of_empty_lines_to_preserve = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test395", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49243 + */ + public void test396() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.insert_space_before_semicolon_in_for = true; + preferences.number_of_empty_lines_to_preserve = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test396", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49187 + */ + public void test397() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.blank_lines_before_package = 2; + preferences.blank_lines_after_package = 0; + preferences.number_of_empty_lines_to_preserve = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test397", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49187 + */ + public void test398() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.blank_lines_before_package = 0; + preferences.blank_lines_after_package = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test398", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49187 + */ + public void test399() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.blank_lines_before_package = 1; + preferences.blank_lines_after_package = 1; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test399", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49187 + */ + public void test400() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_PACKAGE, "2"); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AFTER_PACKAGE, "2"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test400", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49361 + */ + public void test401() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test401", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49361 + */ + public void test402() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test402", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49298 + */ + public void test403() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test403", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49298 + */ + public void test404() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION, JavaCore.DO_NOT_INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test404", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49187 + */ + public void test405() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_PACKAGE, "10"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.tab_size = 4; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test405", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49298 + */ + public void test406() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION, JavaCore.INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test406", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49481 + */ + public void test407() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_size = 4; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.blank_lines_before_first_class_body_declaration = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test407", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49481 + */ + public void test408() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_size = 4; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.blank_lines_before_first_class_body_declaration = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test408", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49378 + */ + public void test409() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK_IN_CASE, DefaultCodeFormatterConstants.NEXT_LINE); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.indent_switchstatements_compare_to_cases = false; + preferences.indent_switchstatements_compare_to_switch = true; + preferences.brace_position_for_block = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.brace_position_for_switch = DefaultCodeFormatterConstants.NEXT_LINE; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test409", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49577 + */ + public void test410() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.blank_lines_between_type_declarations = 1; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test410", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49577 + */ + public void test411() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.blank_lines_between_type_declarations = 2; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test411", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49551 + */ + public void test412() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test412", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49551 + */ + public void test413() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.blank_lines_between_type_declarations = 1; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test413", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49551 + */ + public void test414() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test414", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49551 + */ + public void test415() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.blank_lines_between_type_declarations = 1; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test415", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49551 + */ + public void test416() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.blank_lines_between_type_declarations = 1; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test416", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49571 + */ + public void test417() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_before_opening_paren_in_constructor_declaration = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test417", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49571 + */ + public void test418() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_before_opening_paren_in_constructor_declaration = true; + preferences.insert_space_before_opening_paren_in_method_declaration = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test418", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49298 + */ + public void test421() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION, JavaCore.DO_NOT_INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test421", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49298 + */ + public void test422() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION, JavaCore.DO_NOT_INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.blank_lines_before_first_class_body_declaration = 1; + preferences.tab_size = 4; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test422", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49351 + */ + public void test423() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.END_OF_LINE); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test423", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49351 + */ + public void test424() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test424", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49351 + */ + public void test425() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test425", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49351 + */ + public void test426() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.number_of_empty_lines_to_preserve = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test426", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49351 + */ + public void test427() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.number_of_empty_lines_to_preserve = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test427", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49351 + */ + public void test428() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.number_of_empty_lines_to_preserve = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test428", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49351 + */ + public void test429() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.number_of_empty_lines_to_preserve = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test429", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49351 + */ + public void test430() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.number_of_empty_lines_to_preserve = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test430", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49351 + */ + public void test431() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR, JavaCore.INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.number_of_empty_lines_to_preserve = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test431", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49370 + */ + public void test432() { + String resourcePath = getResource("test432", "formatter.xml"); + Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "AIS"); + assertNotNull("No preferences", options); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test432", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49370 + */ + public void test433() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test433", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49660 + */ + public void test434() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, + DefaultCodeFormatterConstants.createAlignmentValue(true, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + assertEquals(true, DefaultCodeFormatterConstants.getForceWrapping((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION))); + assertEquals(DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.getWrappingStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION))); + assertEquals(DefaultCodeFormatterConstants.INDENT_ON_COLUMN, DefaultCodeFormatterConstants.getIndentStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION))); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.indentation_size = 3; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.insert_space_after_opening_paren_in_method_invocation = true; + preferences.insert_space_before_closing_paren_in_method_invocation = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test434", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49772 + */ + public void test435() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.brace_position_for_method_declaration = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.brace_position_for_block = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.blank_lines_before_first_class_body_declaration = 1; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.tab_size = 4; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test435", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49772 + */ + public void test436() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.brace_position_for_method_declaration = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.brace_position_for_constructor_declaration = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.brace_position_for_block = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.blank_lines_before_first_class_body_declaration = 1; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.tab_size = 4; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test436", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49660 + */ + public void test437() { + String resourcePath = getResource("test437", "formatter.xml"); + Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "Felix"); + assertNotNull("No preferences", options); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test437", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49660 + */ + public void test438() { + String resourcePath = getResource("test438", "formatter.xml"); + Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "Felix"); + assertNotNull("No preferences", options); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test438", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49660 + */ + public void test439() { + String resourcePath = getResource("test439", "formatter.xml"); + Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "Felix"); + assertNotNull("No preferences", options); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test439", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49763 + */ + public void test440() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, DefaultCodeFormatterConstants.FALSE); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test440", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49763 + */ + public void test441() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, DefaultCodeFormatterConstants.FALSE); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test441", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49763 + */ + public void test442() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, DefaultCodeFormatterConstants.FALSE); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test442", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49763 + */ + public void test443() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, DefaultCodeFormatterConstants.FALSE); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, JavaCore.INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test443", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49763 + */ + public void test444() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, DefaultCodeFormatterConstants.FALSE); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test444", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49763 + */ + public void test445() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, DefaultCodeFormatterConstants.FALSE); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test445", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49327 + */ + public void test446() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.number_of_empty_lines_to_preserve = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test446", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49187 + */ + public void test447() { + String resourcePath = getResource("test447", "test447.zip"); + Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "settings.xml", "Toms"); + assertNotNull("No preferences", options); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + String input = getZipEntryContents(resourcePath, getIn("Format.java")); + assertNotNull("No input", input); + String output = getZipEntryContents(resourcePath, getOut("Format.java")); + assertNotNull("No output", output); + int start = input.indexOf("private"); + int end = input.indexOf(";"); + runTest(input, output, codeFormatter, CodeFormatter.K_COMPILATION_UNIT, 0, false, start, end - start + 1, "\r\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49953 + */ + public void test448() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.number_of_empty_lines_to_preserve = 0; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_before_opening_bracket_in_array_allocation_expression = true; + preferences.insert_space_after_opening_bracket_in_array_allocation_expression = true; + preferences.insert_space_before_closing_bracket_in_array_allocation_expression = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test448", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49953 + */ + public void test449() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.number_of_empty_lines_to_preserve = 0; + preferences.insert_space_before_opening_bracket_in_array_allocation_expression = false; + preferences.insert_space_after_opening_bracket_in_array_allocation_expression = true; + preferences.insert_space_before_closing_bracket_in_array_allocation_expression = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test449", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=50225 + */ + public void test450() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test450", "A.java", CodeFormatter.K_UNKNOWN, 0, false, 0, 0);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49187 + */ + public void test451() { + String resourcePath = getResource("test451", "test451.zip"); + Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "settings.xml", "Toms"); + assertNotNull("No preferences", options); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + String input = getZipEntryContents(resourcePath, getIn("Format.java")); + assertNotNull("No input", input); + String output = getZipEntryContents(resourcePath, getOut("Format.java")); + assertNotNull("No output", output); + int start = input.indexOf("private"); + int end = input.indexOf(";"); + runTest(input, output, codeFormatter, CodeFormatter.K_COMPILATION_UNIT, 0, false, start, end - start + 1, "\r\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49187 + */ + public void test452() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_PACKAGE, "2"); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AFTER_PACKAGE, "2"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test452", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=50719 + */ + public void test453() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.blank_lines_before_first_class_body_declaration = 1; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.tab_size = 4; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test453", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=50736 + */ + public void test454() { + String resourcePath = getResource("test454", "test454.zip"); + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1");//$NON-NLS-1$ + assertNotNull("No preferences", options); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + String input = getZipEntryContents(resourcePath, getIn("A.java")); + assertNotNull("No input", input); + String output = getZipEntryContents(resourcePath, getOut("A.java")); + assertNotNull("No output", output); + int start = input.indexOf("launch.setAttribute"); + int end = input.indexOf(";", start + 1); + runTest(input, output, codeFormatter, CodeFormatter.K_COMPILATION_UNIT, 0, false, start, end - start + 1, "\r\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=50736 + */ + public void test455() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1");//$NON-NLS-1$ + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + 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_WRAP_OUTER_EXPRESSIONS_WHEN_NESTED, DefaultCodeFormatterConstants.FALSE); + 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 + */ + public void test456() { + String resourcePath = getResource("test456", "test456.zip"); + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + assertNotNull("No preferences", options); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.number_of_empty_lines_to_preserve = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + String input = getZipEntryContents(resourcePath, getIn("A.java")); + assertNotNull("No input", input); + String output = getZipEntryContents(resourcePath, getOut("A.java")); + assertNotNull("No output", output); + int start = input.indexOf("launch.setAttribute"); + int end = input.indexOf(";", start + 1); + runTest(input, output, codeFormatter, CodeFormatter.K_COMPILATION_UNIT, 0, false, start, end - start + 1, "\r\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=50989 + */ + public void test457() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test457", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * Check null options + */ + public void test458() { + CodeFormatter codeFormatter = ToolFactory.createCodeFormatter(null); + runTest(codeFormatter, "test458", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51158 + */ + public void test459() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, + DefaultCodeFormatterConstants.createAlignmentValue( + true, + DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, + DefaultCodeFormatterConstants.INDENT_BY_ONE + )); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_STRING_CONCATENATION, + DefaultCodeFormatterConstants.createAlignmentValue( + false, + DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, + DefaultCodeFormatterConstants.INDENT_BY_ONE + )); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test459", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51158 + */ + public void test460() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ADDITIVE_OPERATOR, + DefaultCodeFormatterConstants.createAlignmentValue( + false, + DefaultCodeFormatterConstants.WRAP_COMPACT, + DefaultCodeFormatterConstants.INDENT_BY_ONE + )); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test460", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51190 + */ + public void test461() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test461", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51158 + */ + public void test462() { + String resourcePath = getResource("test462", "formatter.xml"); + Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "neils"); + assertNotNull("No preferences", options); + + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, + DefaultCodeFormatterConstants.createAlignmentValue( + true, + DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, + DefaultCodeFormatterConstants.INDENT_DEFAULT)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test462", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=50276 + */ + public void test463() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION, + DefaultCodeFormatterConstants.createAlignmentValue( + false, + DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, + DefaultCodeFormatterConstants.INDENT_DEFAULT)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.number_of_empty_lines_to_preserve = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test463", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51128 + */ + public void test464() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED); + options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK, DefaultCodeFormatterConstants.FALSE); + options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY, DefaultCodeFormatterConstants.TRUE); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); + + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test464", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44642 + * @deprecated + */ + public void test465() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION, + DefaultCodeFormatterConstants.createAlignmentValue( + false, + DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, + DefaultCodeFormatterConstants.INDENT_BY_ONE)); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, + DefaultCodeFormatterConstants.createAlignmentValue( + false, + DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, + DefaultCodeFormatterConstants.INDENT_BY_ONE)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test465", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44642 + * @deprecated + */ + public void test466() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION, + DefaultCodeFormatterConstants.createAlignmentValue( + false, + DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, + DefaultCodeFormatterConstants.INDENT_BY_ONE)); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, + DefaultCodeFormatterConstants.createAlignmentValue( + true, + DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, + DefaultCodeFormatterConstants.INDENT_BY_ONE)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test466", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44642 + * @deprecated + */ + public void test467() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION, + DefaultCodeFormatterConstants.createAlignmentValue( + false, + DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, + DefaultCodeFormatterConstants.INDENT_BY_ONE)); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, + DefaultCodeFormatterConstants.createAlignmentValue( + false, + DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, + DefaultCodeFormatterConstants.INDENT_BY_ONE)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test467", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51128 + */ + public void test468() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1");//$NON-NLS-1$ + + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test468", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51201 + */ + public void test469() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACKETS_IN_ARRAY_ALLOCATION_EXPRESSION, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); + + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test469", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51035 + */ + public void test470() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.keep_simple_if_on_one_line = true; + preferences.keep_guardian_clause_on_one_line = true; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.tab_size = 4; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test470", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51659 + */ + public void test471() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test471", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51659 + */ + public void test472() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test472", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51659 + */ + public void test473() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test473", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51659 + */ + public void test474() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test474", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51659 + */ + public void test475() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test475", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51768 + */ + public void test476() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_TYPE_HEADER, DefaultCodeFormatterConstants.FALSE); + options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK, DefaultCodeFormatterConstants.FALSE); + options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY, DefaultCodeFormatterConstants.FALSE); + options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1"); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AFTER_IMPORTS, "1"); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_IF, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_MULTIPLICATIVE_OPERATOR, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_MULTIPLICATIVE_OPERATOR, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_RELATIONAL_OPERATOR, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_RELATIONAL_OPERATOR, JavaCore.INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test476", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51603 + */ + public void test477() { + String option = + DefaultCodeFormatterConstants.createAlignmentValue( + true, + DefaultCodeFormatterConstants.WRAP_NO_SPLIT, + DefaultCodeFormatterConstants.INDENT_BY_ONE); + assertTrue("Wrong force setting", DefaultCodeFormatterConstants.getForceWrapping(option)); + assertEquals("Wrong wrapping style", DefaultCodeFormatterConstants.WRAP_NO_SPLIT, DefaultCodeFormatterConstants.getWrappingStyle(option)); + assertEquals("Wrong indent style", DefaultCodeFormatterConstants.INDENT_BY_ONE, DefaultCodeFormatterConstants.getIndentStyle(option)); + + option = DefaultCodeFormatterConstants.setForceWrapping(option, false); + assertFalse("Wrong force setting", DefaultCodeFormatterConstants.getForceWrapping(option)); + assertEquals("Wrong wrapping style", DefaultCodeFormatterConstants.WRAP_NO_SPLIT, DefaultCodeFormatterConstants.getWrappingStyle(option)); + assertEquals("Wrong indent style", DefaultCodeFormatterConstants.INDENT_BY_ONE, DefaultCodeFormatterConstants.getIndentStyle(option)); + + option = DefaultCodeFormatterConstants.setIndentStyle(option, DefaultCodeFormatterConstants.INDENT_ON_COLUMN); + assertFalse("Wrong force setting", DefaultCodeFormatterConstants.getForceWrapping(option)); + assertEquals("Wrong wrapping style", DefaultCodeFormatterConstants.WRAP_NO_SPLIT, DefaultCodeFormatterConstants.getWrappingStyle(option)); + assertEquals("Wrong indent style", DefaultCodeFormatterConstants.INDENT_ON_COLUMN, DefaultCodeFormatterConstants.getIndentStyle(option)); + + + option = DefaultCodeFormatterConstants.setIndentStyle(option, DefaultCodeFormatterConstants.INDENT_DEFAULT); + assertFalse("Wrong force setting", DefaultCodeFormatterConstants.getForceWrapping(option)); + assertEquals("Wrong wrapping style", DefaultCodeFormatterConstants.WRAP_NO_SPLIT, DefaultCodeFormatterConstants.getWrappingStyle(option)); + assertEquals("Wrong indent style", DefaultCodeFormatterConstants.INDENT_DEFAULT, DefaultCodeFormatterConstants.getIndentStyle(option)); + + + option = DefaultCodeFormatterConstants.setForceWrapping(option, true); + assertTrue("Wrong force setting", DefaultCodeFormatterConstants.getForceWrapping(option)); + assertEquals("Wrong wrapping style", DefaultCodeFormatterConstants.WRAP_NO_SPLIT, DefaultCodeFormatterConstants.getWrappingStyle(option)); + assertEquals("Wrong indent style", DefaultCodeFormatterConstants.INDENT_DEFAULT, DefaultCodeFormatterConstants.getIndentStyle(option)); + + + option = DefaultCodeFormatterConstants.setWrappingStyle(option, DefaultCodeFormatterConstants.WRAP_COMPACT); + assertTrue("Wrong force setting", DefaultCodeFormatterConstants.getForceWrapping(option)); + assertEquals("Wrong wrapping style", DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.getWrappingStyle(option)); + assertEquals("Wrong indent style", DefaultCodeFormatterConstants.INDENT_DEFAULT, DefaultCodeFormatterConstants.getIndentStyle(option)); + + + option = DefaultCodeFormatterConstants.setWrappingStyle(option, DefaultCodeFormatterConstants.WRAP_COMPACT_FIRST_BREAK); + assertTrue("Wrong force setting", DefaultCodeFormatterConstants.getForceWrapping(option)); + assertEquals("Wrong wrapping style", DefaultCodeFormatterConstants.WRAP_COMPACT_FIRST_BREAK, DefaultCodeFormatterConstants.getWrappingStyle(option)); + assertEquals("Wrong indent style", DefaultCodeFormatterConstants.INDENT_DEFAULT, DefaultCodeFormatterConstants.getIndentStyle(option)); + + option = DefaultCodeFormatterConstants.setWrappingStyle(option, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE); + assertTrue("Wrong force setting", DefaultCodeFormatterConstants.getForceWrapping(option)); + assertEquals("Wrong wrapping style", DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.getWrappingStyle(option)); + assertEquals("Wrong indent style", DefaultCodeFormatterConstants.INDENT_DEFAULT, DefaultCodeFormatterConstants.getIndentStyle(option)); + + option = DefaultCodeFormatterConstants.setWrappingStyle(option, DefaultCodeFormatterConstants.WRAP_NEXT_SHIFTED); + assertTrue("Wrong force setting", DefaultCodeFormatterConstants.getForceWrapping(option)); + assertEquals("Wrong wrapping style", DefaultCodeFormatterConstants.WRAP_NEXT_SHIFTED, DefaultCodeFormatterConstants.getWrappingStyle(option)); + assertEquals("Wrong indent style", DefaultCodeFormatterConstants.INDENT_DEFAULT, DefaultCodeFormatterConstants.getIndentStyle(option)); + + option = DefaultCodeFormatterConstants.setWrappingStyle(option, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE); + assertTrue("Wrong force setting", DefaultCodeFormatterConstants.getForceWrapping(option)); + assertEquals("Wrong wrapping style", DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.getWrappingStyle(option)); + assertEquals("Wrong indent style", DefaultCodeFormatterConstants.INDENT_DEFAULT, DefaultCodeFormatterConstants.getIndentStyle(option)); + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=52246 + */ + public void test478() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_4); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, options); + runTest(codeFormatter, "test478", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=52479 + */ + public void test479() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test479", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=52479 + */ + public void test480() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.number_of_empty_lines_to_preserve = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test480", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=52283 + */ + public void test481() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test481", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=52283 + */ + public void test482() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK, JavaCore.DO_NOT_INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test482", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=52851 + */ + public void test483() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK, JavaCore.DO_NOT_INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test483", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=50989 + */ + public void test484() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1");//$NON-NLS-1$ + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test484", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=50989 + */ + public void test485() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1");//$NON-NLS-1$ + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test485", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=50989 + */ + public void test486() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE);//$NON-NLS-1$ + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, DefaultCodeFormatterConstants.NEXT_LINE);//$NON-NLS-1$ + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE);//$NON-NLS-1$ + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE);//$NON-NLS-1$ + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, DefaultCodeFormatterConstants.NEXT_LINE);//$NON-NLS-1$ + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE);//$NON-NLS-1$ + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test486", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test487() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test487", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test488() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CASE, JavaCore.DO_NOT_INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test488", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test489() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, + DefaultCodeFormatterConstants.createAlignmentValue(true, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test489", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=52747 + */ + public void test490() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER, DefaultCodeFormatterConstants.NEXT_LINE); + options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, + DefaultCodeFormatterConstants.createAlignmentValue(true, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test490", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=59451 + */ + public void _test491() { + String resourcePath = getResource("test491", "formatter.xml"); + Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "DOI"); + assertNotNull("No preferences", options); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test491", "BundleChain.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=59575 + */ + public void test492() { + String resourcePath = getResource("test492", "core_formatting.xml"); + Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "core"); + assertNotNull("No preferences", options); + options.put(JavaCore.COMPILER_PB_NON_NLS_STRING_LITERAL, JavaCore.ERROR); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, options); + runTest(codeFormatter, "test492", "Main.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=59716 + */ + public void test493() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AFTER_PACKAGE, "1"); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_PACKAGE, "1"); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AFTER_IMPORTS, "1"); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_IMPORTS, "1"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test493", "MyClass.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=60035 + */ + public void test494() { + String resourcePath = getResource("test494", "format.xml"); + Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "AGPS default"); + assertNotNull("No preferences", options); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, options); + runTest(codeFormatter, "test494", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=58565 + */ + public void test495() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.blank_lines_before_first_class_body_declaration = 1; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.tab_size = 4; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test495", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=58565 + */ + public void test496() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_size = 4; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.keep_simple_if_on_one_line = true; + preferences.keep_guardian_clause_on_one_line = true; + preferences.blank_lines_before_first_class_body_declaration = 1; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test496", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test497() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.blank_lines_before_first_class_body_declaration = 1; + preferences.tab_size = 4; + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test497", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test498() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.keep_simple_if_on_one_line = true; + preferences.keep_guardian_clause_on_one_line = true; + preferences.tab_size = 4; + preferences.align_selector_in_method_invocation_on_expression_first_line = false; + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test498", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test499() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.blank_lines_before_first_class_body_declaration = 1; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.tab_size = 4; + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test499", "A.java", CodeFormatter.K_COMPILATION_UNIT, true);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test500() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test500", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=68506 + */ + public void test501() { + String resourcePath = getResource("test501", "formatter.xml"); + Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "GMTI"); + assertNotNull("No preferences", options); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test501", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=69806 + */ + public void test502() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_size = 4; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test502", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * Formatting foreach + */ + public void test503() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_size = 4; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test503", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * Formatting parameterized type + */ + public void test504() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test504", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * Formatting parameterized type + */ + public void test505() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_size = 4; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test505", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * Formatting parameterized type + */ + public void test506() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_size = 4; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + setPageWidth80(preferences); + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test506", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * Formatting enum declaration + */ + public void test507() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_size = 4; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test507", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * Formatting annotation type declaration + */ + public void test508() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test508", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=68506 + */ + public void test509() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.keep_simple_if_on_one_line = true; + preferences.keep_then_statement_on_same_line = true; + preferences.keep_guardian_clause_on_one_line = true; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.compact_else_if = true; + preferences.insert_new_line_at_end_of_file_if_missing = true; + preferences.number_of_empty_lines_to_preserve = 0; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter,"test509", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=68506 + */ + public void test510() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.keep_simple_if_on_one_line = true; + preferences.keep_then_statement_on_same_line = true; + preferences.keep_guardian_clause_on_one_line = true; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.compact_else_if = true; + preferences.insert_new_line_at_end_of_file_if_missing = false; + preferences.number_of_empty_lines_to_preserve = 1; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter,"test510", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=68506 + */ + public void test511() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.keep_simple_if_on_one_line = true; + preferences.keep_then_statement_on_same_line = true; + preferences.keep_guardian_clause_on_one_line = true; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.compact_else_if = true; + preferences.insert_new_line_at_end_of_file_if_missing = false; + preferences.number_of_empty_lines_to_preserve = 1; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter,"test511", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=68506 + */ + public void test512() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); + preferences.keep_simple_if_on_one_line = true; + preferences.keep_then_statement_on_same_line = true; + preferences.keep_guardian_clause_on_one_line = true; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.compact_else_if = true; + preferences.insert_new_line_at_end_of_file_if_missing = true; + preferences.number_of_empty_lines_to_preserve = 1; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter,"test512", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=73371 + */ + public void test513() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test513", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=75488 + */ + public void test514() { + String resourcePath = getResource("test514", "formatter.xml"); + Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "core"); + assertNotNull("No preferences", options); + options.put(JavaCore.COMPILER_PB_NON_NLS_STRING_LITERAL, JavaCore.ERROR); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, options); + runTest(codeFormatter, "test514", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=75720 + */ + public void test515() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_size = 4; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test515", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=75720 + */ + public void test516() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ELLIPSIS, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ELLIPSIS, JavaCore.DO_NOT_INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test516", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=75720 + */ + public void test517() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ELLIPSIS, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ELLIPSIS, JavaCore.INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test517", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=75720 + */ + public void test518() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ELLIPSIS, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ELLIPSIS, JavaCore.INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test518", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=75720 + */ + public void test519() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ELLIPSIS, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ELLIPSIS, JavaCore.DO_NOT_INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test519", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * Formatting enum declaration + */ + public void test520() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test520", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=76642 + */ + public void test521() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test521", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=76642 + */ + public void test522() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test522", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=76766 + */ + public void test523() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + preferences.keep_enum_constant_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_enum_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test523", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=76766 + */ + public void test524() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + preferences.keep_enum_constant_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_enum_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test524", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=76766 + */ + public void test525() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + preferences.keep_enum_constant_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + preferences.keep_enum_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test525", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=76766 + */ + public void test526() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + preferences.keep_enum_constant_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + preferences.keep_enum_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test526", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=77249 + */ + public void test527() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.tab_size = 4; + setPageWidth80(preferences); + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test527", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + public void test527b() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.tab_size = 4; + preferences.alignment_for_arguments_in_annotation = Alignment.M_COMPACT_SPLIT; + setPageWidth80(preferences); + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test527b", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=79779 + */ + public void test528() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test528", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=79779 + */ + public void test529() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test529", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=79795 + */ + public void test530() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test530", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=79795 + */ + public void test531() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test531", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=79795 + */ + public void test532() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test532", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=79795 + */ + public void test533() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test533", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=78698 + */ + public void test534() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test534", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=78698 + */ + public void test535() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test535", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=78698 + */ + public void test536() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_after_question_in_wilcard = true; + preferences.insert_space_before_question_in_wilcard = true; + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test536", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=78698 + */ + public void test537() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.insert_space_after_question_in_wilcard = true; + preferences.insert_space_before_question_in_wilcard = true; + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test537", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=83078 + */ + public void test538() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getJavaConventionsSettings()); + preferences.tab_size = 4; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter,"test538", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=83515 + */ + public void test539() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test539", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=83515 + */ + public void test540() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test540", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=83684 + */ + public void test541() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.tab_size = 4; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test541", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + public void test542() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getJavaConventionsSettings()); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.tab_size = 4; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test542", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test543() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getJavaConventionsSettings()); + preferences.tab_size = 4; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test543", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=86410 + */ + public void test544() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_size = 4; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.insert_space_after_closing_angle_bracket_in_type_parameters = true; + preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test544", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=86878 + */ + public void test545() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_size = 4; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test545", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=86908 + */ + public void test546() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_size = 4; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test546", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * Add support for comment formatting + */ + public void test547() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.tab_size = 4; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test547", "A.java", CodeFormatter.K_MULTI_LINE_COMMENT, false);//$NON-NLS-1$ //$NON-NLS-2$ + + runTest(codeFormatter, "test547", "A.java", CodeFormatter.K_UNKNOWN, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * Add support for comment formatting + */ + public void test548() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.tab_size = 4; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test548", "A.java", CodeFormatter.K_JAVA_DOC, false);//$NON-NLS-1$ //$NON-NLS-2$ + + runTest(codeFormatter, "test548", "A.java", CodeFormatter.K_UNKNOWN, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=73104 + public void test549() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.MIXED; + preferences.indentation_size = 4; + preferences.tab_size = 8; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test549", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=73104 + public void test550() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.MIXED; + preferences.indentation_size = 4; + preferences.tab_size = 8; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test550", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=73104 + public void test551() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + assertEquals(false, DefaultCodeFormatterConstants.getForceWrapping((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION))); + assertEquals(DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.getWrappingStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION))); + assertEquals(DefaultCodeFormatterConstants.INDENT_ON_COLUMN, DefaultCodeFormatterConstants.getIndentStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION))); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.MIXED; + preferences.indentation_size = 4; + preferences.tab_size = 8; + preferences.page_width = 57; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test551", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=73104 + public void test552() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + assertEquals(false, DefaultCodeFormatterConstants.getForceWrapping((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION))); + assertEquals(DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.getWrappingStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION))); + assertEquals(DefaultCodeFormatterConstants.INDENT_ON_COLUMN, DefaultCodeFormatterConstants.getIndentStyle((String) options.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION))); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.MIXED; + preferences.indentation_size = 4; + preferences.tab_size = 8; + preferences.page_width = 57; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test552", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * Add support for comment formatting + */ + public void test553() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.comment_format_line_comment_starting_on_first_column = true; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.tab_size = 4; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test553", "A.java", CodeFormatter.K_SINGLE_LINE_COMMENT, false);//$NON-NLS-1$ //$NON-NLS-2$ + + runTest(codeFormatter, "test553", "A.java", CodeFormatter.K_UNKNOWN, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * Add support for comment formatting + */ + public void test554() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.comment_format_line_comment_starting_on_first_column = true; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.tab_size = 4; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test554", "A.java", CodeFormatter.K_SINGLE_LINE_COMMENT, false);//$NON-NLS-1$ //$NON-NLS-2$ + + runTest(codeFormatter, "test554", "A.java", CodeFormatter.K_UNKNOWN, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=73104 + public void test555() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.MIXED; + preferences.indentation_size = 4; + preferences.tab_size = 8; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test555", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /* + * Empty array initializer formatting + */ + public void test556() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.tab_size = 4; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test556", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /* + * Empty array initializer formatting + */ + public void test557() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_size = 4; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.keep_empty_array_initializer_on_one_line = true; + preferences.insert_space_between_empty_braces_in_array_initializer = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test557", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * Initial test for bug 89302 + * This test was deprecated in order to test backward compatibility + * after the integration of the fix for bug 122247 + * @deprecated + * @see bug 122247 + */ + public void test558() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_ENUM_CONSTANT, null); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD, null); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD, null); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE, null); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE, null); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER, null); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, null); + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247: use deprecated option + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION, JavaCore.DO_NOT_INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_size = 4; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.insert_space_after_comma_in_enum_declarations = false; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test558", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + /** + * Initial test for bug 89302 + * This test was deprecated in order to test backward compatibility + * after the integration of the fix for bug 122247 + * @deprecated + * @see bug 122247 + */ + public void test559() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_ENUM_CONSTANT, null); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD, null); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD, null); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE, null); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE, null); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER, null); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, null); + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247: use deprecated option + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION, JavaCore.DO_NOT_INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_size = 4; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.insert_space_after_comma_in_enum_declarations = true; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test559", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=81497 + public void test560() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_size = 4; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.brace_position_for_array_initializer = DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED; + preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.brace_position_for_method_declaration = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.brace_position_for_block = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.keep_empty_array_initializer_on_one_line = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test560", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=81497 + public void test561() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.tab_size = 4; + preferences.brace_position_for_array_initializer = DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED; + preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.brace_position_for_method_declaration = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.brace_position_for_block = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.keep_empty_array_initializer_on_one_line = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test561", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=89318 + public void test562() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.tab_size = 4; + preferences.insert_space_after_closing_angle_bracket_in_type_arguments = false; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test562", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=89318 + public void test563() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_size = 4; + preferences.tab_size = 4; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.insert_space_after_closing_angle_bracket_in_type_arguments = true; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test563", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=89299 + public void test564() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.tab_size = 4; + preferences.brace_position_for_array_initializer = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.brace_position_for_method_declaration = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.brace_position_for_block = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.keep_empty_array_initializer_on_one_line = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test564", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /*// https://bugs.eclipse.org/bugs/show_bug.cgi?id=49896 + public void test565() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION, + DefaultCodeFormatterConstants.createAlignmentValue(true, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.use_tabs_only_for_leading_indentations = true; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test565", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + }*/ + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=73658 + public void test566() { + Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_size = 4; + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.brace_position_for_enum_constant = DefaultCodeFormatterConstants.NEXT_LINE; + preferences.brace_position_for_enum_declaration = DefaultCodeFormatterConstants.NEXT_LINE; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test566", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=49896 + public void test567() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.use_tabs_only_for_leading_indentations = true; + preferences.page_width = 35; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test567", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=49896 + public void test568() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.indentation_size = 4; + preferences.tab_size = 4; + preferences.tab_char = DefaultCodeFormatterOptions.MIXED; + preferences.use_tabs_only_for_leading_indentations = true; + preferences.page_width = 35; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test568", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=49896 + public void test569() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.indentation_size = 4; + preferences.tab_size = 4; + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.use_tabs_only_for_leading_indentations = false; + preferences.page_width = 40; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test569", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=77809 + public void test570() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test570", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=77809 + public void test571() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS, + DefaultCodeFormatterConstants.createAlignmentValue(true, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test571", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90213 + public void test572() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.insert_space_after_opening_brace_in_array_initializer = false; + preferences.insert_space_before_closing_brace_in_array_initializer = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test572", "A.java", CodeFormatter.K_STATEMENTS, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90213 + public void test573() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test573", "A.java", CodeFormatter.K_STATEMENTS, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=91238 + public void test574() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=102780 + preferences.comment_indent_root_tags = false; + preferences.comment_align_tags_descriptions_grouped = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test574", "A.java", CodeFormatter.K_JAVA_DOC, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * Initial test for bug 77809 + * This test was deprecated in order to test backward compatibility + * after the integration of the fix for bug 122247 + * @deprecated + * @see bug 122247 + */ + + public void test575() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_ENUM_CONSTANT, null); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD, null); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD, null); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE, null); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE, null); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER, null); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, null); + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247: use deprecated option + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION, JavaCore.INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test575", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=95431 + public void test576() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test576", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=98037 + public void test577() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test577", "A.java", CodeFormatter.K_UNKNOWN, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=98037 + public void test578() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test578", "A.java", CodeFormatter.K_UNKNOWN, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=98139 + public void test579() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test579", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=98139 + public void test580() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test580", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=99084 + public void test581() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test581", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=99084 + public void test582() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.insert_space_after_closing_angle_bracket_in_type_arguments = false; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test582", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=100062 + public void test583() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test583", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=49896 + public void test584() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, DefaultCodeFormatterConstants.TRUE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, DefaultCodeFormatterConstants.MIXED); + options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "65"); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test584", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=49896 + public void test585() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, DefaultCodeFormatterConstants.TRUE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, DefaultCodeFormatterConstants.MIXED); + options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "80"); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test585", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=49896 + public void test586() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, DefaultCodeFormatterConstants.TRUE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "65"); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test586", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=49896 + public void test587() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, DefaultCodeFormatterConstants.TRUE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "80"); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test587", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=101230 + public void test588() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test588", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=104796 + public void test589() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test589", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=103706 + public void test590() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES, DefaultCodeFormatterConstants.TRUE); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test590", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=103706 + public void test591() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES, DefaultCodeFormatterConstants.FALSE); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test591", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=98089 + public void test592() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "60"); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); + options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, JavaCore.INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test592", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=71766 + public void test593() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ASSIGNMENT, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NO_SPLIT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test593", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=71766 + public void test594() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ASSIGNMENT, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test594", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=71766 + public void test595() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ASSIGNMENT, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test595", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=71766 + public void test596() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ASSIGNMENT, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test596", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=87193 + public void test597() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, DefaultCodeFormatterConstants.MIXED); + options.put(DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, DefaultCodeFormatterConstants.TRUE); + options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "60"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test597", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=87193 + public void test598() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + options.put(DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, DefaultCodeFormatterConstants.TRUE); + options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "60"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test598", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=87193 + public void test599() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + options.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION, "1"); + options.put(DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, DefaultCodeFormatterConstants.TRUE); + options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "60"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test599", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + // test Scribe2.hasNLSTag() + public void test600() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test600", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + // Binary expression + public void test601() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + String alignment = DefaultCodeFormatterConstants.createAlignmentValue(true, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT); + options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ADDITIVE_OPERATOR, alignment); + options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_MULTIPLICATIVE_OPERATOR, alignment); + options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_LOGICAL_OPERATOR, alignment); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + options.put(DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, DefaultCodeFormatterConstants.TRUE); + options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "60"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test601", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=108916 + public void test605() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS, + DefaultCodeFormatterConstants.createAlignmentValue( + true, + DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, + DefaultCodeFormatterConstants.INDENT_DEFAULT)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test605", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=110304 + public void test606() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_RETURN, JavaCore.DO_NOT_INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test606", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=111270 + public void test607() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test607", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=111270 + public void test608() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test608", "A.java", CodeFormatter.K_JAVA_DOC, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=116858 + public void test609() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.indent_switchstatements_compare_to_cases = true; + preferences.indent_switchstatements_compare_to_switch = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test609", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=122914 + */ + public void test610() { + String resourcePath = getResource("test610", "formatter.xml"); + Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "mhdk"); + assertNotNull("No preferences", options); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test610", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=111446 + */ + public void test611() { + { + // only tabs, indentation size = 4, tab size = 4 + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.tab_size = 4; + preferences.indentation_size = 4; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + assertEquals("Wrong indentation string", "\t", codeFormatter.createIndentationString(1)); + assertEquals("Wrong indentation string", "\t\t", codeFormatter.createIndentationString(2)); + assertEquals("Wrong indentation string", "\t\t\t", codeFormatter.createIndentationString(3)); + } + { + // only tabs, indentation size = 8, tab size = 8 + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.TAB; + preferences.tab_size = 8; + preferences.indentation_size = 8; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + assertEquals("Wrong indentation string", "\t", codeFormatter.createIndentationString(1)); + assertEquals("Wrong indentation string", "\t\t", codeFormatter.createIndentationString(2)); + assertEquals("Wrong indentation string", "\t\t\t", codeFormatter.createIndentationString(3)); + } + { + // only spaces, indentation size = 2, tab size = 4 + // tab size is ignored + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.SPACE; + preferences.tab_size = 4; + preferences.indentation_size = 2; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + assertEquals("Wrong indentation string", " ", codeFormatter.createIndentationString(1)); + assertEquals("Wrong indentation string", " ", codeFormatter.createIndentationString(2)); + assertEquals("Wrong indentation string", " ", codeFormatter.createIndentationString(3)); + } + { + // mixed, indentation size = 4 tab size = 2 + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.MIXED; + preferences.tab_size = 2; + preferences.indentation_size = 4; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + assertEquals("Wrong indentation string", "\t\t", codeFormatter.createIndentationString(1)); + assertEquals("Wrong indentation string", "\t\t\t\t", codeFormatter.createIndentationString(2)); + } + { + // mixed, indentation size = 2, tab size = 4 + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.tab_char = DefaultCodeFormatterOptions.MIXED; + preferences.tab_size = 4; + preferences.indentation_size = 2; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + assertEquals("Wrong indentation string", " ", codeFormatter.createIndentationString(1)); + assertEquals("Wrong indentation string", "\t", codeFormatter.createIndentationString(2)); + assertEquals("Wrong indentation string", "\t ", codeFormatter.createIndentationString(3)); + } + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=126625 + public void test612() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.indent_body_declarations_compare_to_annotation_declaration_header = false; + preferences.indent_body_declarations_compare_to_type_header = true; + preferences.keep_annotation_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test612", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=126625 + public void test613() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.indent_body_declarations_compare_to_annotation_declaration_header = true; + preferences.indent_body_declarations_compare_to_type_header = false; + preferences.keep_annotation_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + preferences.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test613", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=128848 + public void test614() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test614", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=128848 + public void test615() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test615", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=128848 + public void test616() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test616", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=131013 + public void test617() { + String resourcePath = getResource("test617", "formatter.xml"); + Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "JRK"); + assertNotNull("No preferences", options); + options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_STRING_CONCATENATION, + DefaultCodeFormatterConstants.createAlignmentValue( + true, + DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, + DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test617", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=137224 + public void test618() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test618", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=137224 + public void test619() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test619", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=139291 + public void test620() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS, JavaCore.DO_NOT_INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test620", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=139291 + public void test621() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS, JavaCore.DO_NOT_INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test621", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=148370 + public void test622() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test622", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=148370 + public void test623() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test623", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=148370 + public void test624() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test624", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=102728 + public void test625() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_STRING_CONCATENATION, + DefaultCodeFormatterConstants.createAlignmentValue( + true, + DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, + DefaultCodeFormatterConstants.INDENT_DEFAULT)); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test625", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=152725 + public void test626() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test626", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=158267 + public void test627() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test627", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=158267 + public void test628() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test628", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=158267 + public void test629() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test629", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=158267 + public void test630() { + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipseDefaultSettings()); + preferences.insert_space_after_opening_paren_in_parenthesized_expression = true; + preferences.insert_space_before_closing_paren_in_parenthesized_expression = true; + preferences.insert_space_before_parenthesized_expression_in_throw = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test630", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=158267 + public void test631() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_THROW, JavaCore.INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test631", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=158267 + public void test632() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_RETURN, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_THROW, JavaCore.DO_NOT_INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test632", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=165210 + public void test633() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BETWEEN_IMPORT_GROUPS, "3"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test633", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=165210 + public void test634() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BETWEEN_IMPORT_GROUPS, "1"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test634", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=165210 + public void test635() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BETWEEN_IMPORT_GROUPS, "1"); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AFTER_IMPORTS, "0"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test635", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=165210 + public void test636() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BETWEEN_IMPORT_GROUPS, "3"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test636", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=165210 + public void test637() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BETWEEN_IMPORT_GROUPS, "2"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test637", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=165210 + public void test638() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BETWEEN_IMPORT_GROUPS, "1"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test638", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=165210 + public void test639() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BETWEEN_IMPORT_GROUPS, "2"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test639", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=165210 + public void test640() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BETWEEN_IMPORT_GROUPS, "1"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test640", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=168109 + public void test641() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, DefaultCodeFormatterConstants.MIXED); + options.put(DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, DefaultCodeFormatterConstants.TRUE); + options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "36"); + options.put(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, "2"); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test641", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=166962 + public void test642() { + String resourcePath = getResource("test642", "formatter.xml"); + Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "Visionnaire"); + assertNotNull("No preferences", options); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test642", "A.java", CodeFormatter.K_COMPILATION_UNIT);//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=171634 + public void test643() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING, JavaCore.INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test643", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=171634 + public void test644() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING, JavaCore.INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test644", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=171634 + public void test645() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING, JavaCore.INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test645", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=171634 + public void test646() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING, JavaCore.DO_NOT_INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test646", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=171634 + public void test647() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING, JavaCore.DO_NOT_INSERT); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test647", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=171634 + public void test648() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING, JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "0"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test648", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=171634 + public void test649() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING, JavaCore.INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "0"); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test649", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=172848 + public void test650() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test650", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=172848 + public void test651() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test651", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=172848 + public void test652() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test652", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=172848 + public void test653() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test653", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=172848 + public void test654() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test654", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=172848 + public void test655() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test655", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test656() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.indent_empty_lines = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test656", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + public void test657() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.indent_empty_lines = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test657", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=20793 + public void test658() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.never_indent_block_comments_on_first_column = false; + preferences.never_indent_line_comments_on_first_column = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test658", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=20793 + public void test659() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.never_indent_block_comments_on_first_column = true; + preferences.never_indent_line_comments_on_first_column = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test659", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=20793 + public void test660() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.never_indent_block_comments_on_first_column = false; + preferences.never_indent_line_comments_on_first_column = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test660", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=20793 + public void test661() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.never_indent_block_comments_on_first_column = true; + preferences.never_indent_line_comments_on_first_column = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test661", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=20793 + public void test662() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.never_indent_block_comments_on_first_column = true; + preferences.never_indent_line_comments_on_first_column = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test662", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=20793 + public void test663() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.never_indent_block_comments_on_first_column = true; + preferences.never_indent_line_comments_on_first_column = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test663", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=79068 + */ + public void test664() { + Map options = DefaultCodeFormatterConstants.getEclipse21Settings(); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, + DefaultCodeFormatterConstants.createAlignmentValue( + true, + DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, + DefaultCodeFormatterConstants.INDENT_BY_ONE + )); + options.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_STRING_CONCATENATION, + DefaultCodeFormatterConstants.createAlignmentValue( + false, + DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, + DefaultCodeFormatterConstants.INDENT_BY_ONE + )); + options.put(DefaultCodeFormatterConstants.FORMATTER_WRAP_BEFORE_STRING_CONCATENATION, DefaultCodeFormatterConstants.FALSE); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test664", "A.java", CodeFormatter.K_STATEMENTS);//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=49314 + public void test665() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.never_indent_block_comments_on_first_column = true; + preferences.never_indent_line_comments_on_first_column = true; + preferences.comment_format_block_comment = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test665", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=172324 + public void test666() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.never_indent_block_comments_on_first_column = true; + preferences.never_indent_line_comments_on_first_column = true; + preferences.comment_format_block_comment = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test666", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=192285 + public void test667() { + Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test667", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=198362 + public void test668() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test668", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203020 + public void test669() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test669", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203020 + public void test670() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test670", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 + public void test671() { + /* old version + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(59, 20), + new Region(101, 20) + }; + runTest(codeFormatter, "test671", "A.java", CodeFormatter.K_COMPILATION_UNIT, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + */ + String source = + "public class A {\n" + + " public static void main(String[] args) {\n" + + "[# int a = 1;#]\n" + + " int b = 2;\n" + + "[# int c = 3;#]\n" + + " }\n" + + "}\n"; + formatSource(source, + "public class A {\n" + + " public static void main(String[] args) {\n" + + " int a = 1;\n" + + " int b = 2;\n" + + " int c = 3;\n" + + " }\n" + + "}\n", + CodeFormatter.K_COMPILATION_UNIT, + 0 /*no indentation*/, + true /*repeat formatting twice*/ + ); + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 + public void test672() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(0, 18), + new Region(38, 18) + }; + runTest(codeFormatter, "test672", "A.java", CodeFormatter.K_STATEMENTS, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 + public void test673() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(0, 9), + new Region(19, 19) + }; + runTest(codeFormatter, "test673", "A.java", CodeFormatter.K_EXPRESSION, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 + public void test674() { + /* old version + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(44, 126), + new Region(276, 54) + }; + runTest(codeFormatter, "test674", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + */ + String source = + "public class A {\n" + + " \n" + + " \n" + + " private class Inner1 {[#\n" + + " \n" + + " \n" + + " void bar () { }\n" + + " \n" + + " void i()\n" + + " {\n" + + " \n" + + " }\n" + + " #]}\n" + + " \n" + + " \n" + + " private class Inner2 {\n" + + " void xy() {\n" + + " \n" + + " }\n" + + " }\n" + + "}\n" + + "class B {[#\n" + + " private void foo() {\n" + + " \n" + + " }\n" + + "#]}\n"; + formatSource(source, + "public class A {\n" + + " \n" + + " \n" + + " private class Inner1 {\n" + + "\n" + + " void bar() {\n" + + " }\n" + + "\n" + + " void i() {\n" + + "\n" + + " }\n" + + " }\n" + + " \n" + + " \n" + + " private class Inner2 {\n" + + " void xy() {\n" + + " \n" + + " }\n" + + " }\n" + + "}\n" + + "class B {\n" + + " private void foo() {\n" + + "\n" + + " }\n" + + "}\n", + CodeFormatter.K_CLASS_BODY_DECLARATIONS, + 0 /*no indentation*/, + true /*repeat formatting twice*/ + ); + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 + // NOT_FIXED_YET: https://bugs.eclipse.org/bugs/show_bug.cgi?id=204091 + public void _test675() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(10, 20), + new Region(50, 14), + new Region(68, 25) + }; + runTest(codeFormatter, "test675", "A.java", CodeFormatter.K_MULTI_LINE_COMMENT, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 + // NOT_FIXED_YET: https://bugs.eclipse.org/bugs/show_bug.cgi?id=204091 + public void _test676() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(3, 16), + new Region(31, 16) + }; + runTest(codeFormatter, "test676", "A.java", CodeFormatter.K_SINGLE_LINE_COMMENT, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 + // NOT_FIXED_YET: https://bugs.eclipse.org/bugs/show_bug.cgi?id=204091 + public void _test677() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(4, 16), + new Region(32, 16) + }; + runTest(codeFormatter, "test677", "A.java", CodeFormatter.K_JAVA_DOC, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 + public void test678() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(59, 20), + new Region(101, 20) + }; + runTest(codeFormatter, "test671", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 + public void test679() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(0, 18), + new Region(38, 18) + }; + runTest(codeFormatter, "test672", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 + public void test680() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(0, 9), + new Region(19, 19) + }; + runTest(codeFormatter, "test673", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 + public void test681() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(44, 126), + new Region(276, 54) + }; + runTest(codeFormatter, "test674", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=204091 +// +// // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 +// public void test682() { +// final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); +// DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); +// DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); +// IRegion[] regions = new IRegion[] { +// new Region(10, 20), +// new Region(50, 14), +// new Region(68, 25) +// }; +// runTest(codeFormatter, "test675", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ +// } +// +// // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 +// public void test683() { +// final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); +// DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); +// DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); +// IRegion[] regions = new IRegion[] { +// new Region(3, 16), +// new Region(31, 16) +// }; +// runTest(codeFormatter, "test676", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ +// } +// +// // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 +// public void test684() { +// final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); +// DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); +// DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); +// IRegion[] regions = new IRegion[] { +// new Region(4, 16), +// new Region(32, 16) +// }; +// runTest(codeFormatter, "test677", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ +// } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 + public void test685() { + /* old version + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(18, 35) + }; + runTest(codeFormatter, "test685", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + */ + String source = + "public class A {\n" + + " [# int i=1; #] \n" + + "}\n"; + // Note that whitespaces outside the region are kept after the formatting + // This is intentional since fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=234583 + // The formatter should not touch code outside the given region(s)... + formatSource(source, + "public class A {\n" + + " int i = 1; \n" + + "}\n", + CodeFormatter.K_UNKNOWN, + 0 /*no indentation*/, + true /*repeat formatting twice*/ + ); + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 + public void test686() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test685", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 + public void test687() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(17, 25) + }; + runTest(codeFormatter, "test687", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 + public void test688a() { + /* old version + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(18, 48) + }; + runTest(codeFormatter, "test688", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + */ + String source = + "public class A {\n" + + " [# int i=1; \n" + + "}#]\n"; + // Note that whitespaces outside the region are kept after the formatting + // This is intentional since fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=234583 + // The formatter should not touch code outside the given region(s)... + formatSource(source, + "public class A {\n" + + " int i = 1;\n" + + "}\n", + CodeFormatter.K_UNKNOWN, + 0 /*no indentation*/, + true /*repeat formatting twice*/ + ); + } + + public void test688b() { + /* old version + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(18, 49) + }; + runTest(codeFormatter, "test688", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + */ + String source = + "public class A {\n" + + " [# int i=1; \n" + + "}\n#]"; + // Note that whitespaces outside the region are kept after the formatting + // This is intentional since fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=234583 + // The formatter should not touch code outside the given region(s)... + formatSource(source, + "public class A {\n" + + " int i = 1;\n" + + "}\n" + ); + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 + public void test689() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.line_separator = "\n";//$NON-NLS-1$ + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(31, 23) + }; + runTest(codeFormatter, "test689", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 + public void test690() { + /* old version + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.line_separator = "\r";//$NON-NLS-1$ + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(31, 23) + }; + runTest(codeFormatter, "test689", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\r");//$NON-NLS-1$ //$NON-NLS-2$ + */ + this.formatterPrefs.line_separator = "\r";//$NON-NLS-1$ + String source = + "package pkg1;\n" + + "public class A {\n" + + "[# int i = 1; #]\n" + + "\n" + + "}\n"; + // Note that whitespaces outside the region are kept after the formatting + // This is intentional since fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=234583 + // The formatter should not touch code outside the given region(s)... + formatSource(source, + "package pkg1;\n" + + "public class A {\n" + + " int i = 1;\n" + + "\n" + + "}\n", + CodeFormatter.K_UNKNOWN, + 0 /*no indentation*/, + true /*repeat formatting twice*/ + ); + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 + public void test691() { + /* old version + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.line_separator = "\r\n";//$NON-NLS-1$ + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(31, 22) + }; + runTest(codeFormatter, "test689", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\r\n");//$NON-NLS-1$ //$NON-NLS-2$ + */ + this.formatterPrefs.line_separator = "\r\n";//$NON-NLS-1$ + String source = + "package pkg1;\n" + + "public class A {\n" + + "[# int i = 1; #] \n" + + "\n" + + "}\n"; + // Note that whitespaces outside the region are kept after the formatting + // This is intentional since fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=234583 + // The formatter should not touch code outside the given region(s)... + formatSource(source, + "package pkg1;\n" + + "public class A {\n" + + " int i = 1; \n" + + "\n" + + "}\n", + CodeFormatter.K_UNKNOWN, + 0 /*no indentation*/, + true /*repeat formatting twice*/ + ); + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 + public void test692() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.page_width = 999; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(83, 41) + }; + runTest(codeFormatter, "test692", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=210922 + public void test693() { + final class MyRegion implements IRegion { + public int getLength() { + return 0; + } + public int getOffset() { + return 0; + } + } + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.line_separator = "\n";//$NON-NLS-1$ + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new MyRegion() + }; + runTest(codeFormatter, "test693", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=213283 + public void test694a() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.line_separator = "\n";//$NON-NLS-1$ + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(33, 32) + }; + runTest(codeFormatter, "test694", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=213283 + public void test694b() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.line_separator = "\n";//$NON-NLS-1$ + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(33, 33) + }; + runTest(codeFormatter, "test694", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=213284 + public void test695() { + /* old version + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.line_separator = "\n";//$NON-NLS-1$ + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(59, 1) + }; + runTest(codeFormatter, "test695", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + */ + String source = + "package test1;\n" + + "public class A {\n" + + "\n" + + " public int field;\n" + + "[#\n#]" + + "\n" + + "}\r\n"; + // Note that whitespaces outside the region are kept after the formatting + // This is intentional since fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=234583 + // The formatter should not touch code outside the given region(s)... + formatSource(source, + "package test1;\n" + + "public class A {\n" + + "\n" + + " public int field;\n" + + "\n" + + "}\r\n", + CodeFormatter.K_UNKNOWN, + 0 /*no indentation*/, + true /*repeat formatting twice*/ + ); + } + + // variation on bugs 208541, 213283, 213284 + public void test696a() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.line_separator = "\n";//$NON-NLS-1$ + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(17, 56) + }; + runTest(codeFormatter, "test696a", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // variation on bugs 208541, 213283, 213284 + public void test696b() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.line_separator = "\n";//$NON-NLS-1$ + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(17, 57) + }; + runTest(codeFormatter, "test696b", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // variation on bugs 208541, 213283, 213284 + public void test697a() { + /* old version + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.line_separator = "\n";//$NON-NLS-1$ + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(17, 55) // end of line selection + }; + runTest(codeFormatter, "test697", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + */ + String source = + "public class A {\n" + + "[# \n" + + " \n" + + " \n" + + " int i = 1; #]\n" + + "\n" + + "\n" + + "\n" + + "}\n" + + ""; + // Note that whitespaces outside the region are kept after the formatting + // This is intentional since fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=234583 + // The formatter should not touch code outside the given region(s)... + formatSource(source, + "public class A {\n" + + "\n" + + " int i = 1;\n" + + "\n" + + "\n" + + "\n" + + "}\n", + CodeFormatter.K_UNKNOWN, + 0 /*no indentation*/, + true /*repeat formatting twice*/ + ); + } + + // variation on bugs 208541, 213283, 213284 + public void test697b() { + /* old version + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.line_separator = "\n";//$NON-NLS-1$ + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(17, 56) // end of line selection + 1 + }; + runTest(codeFormatter, "test697", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + */ + String source = + "public class A {\n" + + "[# \n" + + " \n" + + " \n" + + " int i = 1; \n" + + "#]\n" + + "\n" + + "\n" + + "}\n" + + ""; + // Note that whitespaces outside the region are kept after the formatting + // This is intentional since fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=234583 + // The formatter should not touch code outside the given region(s)... + formatSource(source, + "public class A {\n" + + "\n" + + " int i = 1;\n" + + "\n" + + "\n" + + "}\n", + CodeFormatter.K_UNKNOWN, + 0 /*no indentation*/, + true /*repeat formatting twice*/ + ); + } + + // variation on bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 +// public void test698() { +// final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); +// DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); +// preferences.line_separator = "\n";//$NON-NLS-1$ +// DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); +// IRegion[] regions = new IRegion[] { +// new Region(17, 40) // partial line selection +// }; +// runTest(codeFormatter, "test698", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ +// } + + // variation on bugs 208541, 213283, 213284 + public void test699() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.line_separator = "\n";//$NON-NLS-1$ + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(0, 78) // nothing selected --> format all + }; + runTest(codeFormatter, "test699", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 + public void test700() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.line_separator = "\n";//$NON-NLS-1$ + preferences.insert_new_line_after_annotation_on_parameter = false; // override default + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(0, 221) // nothing selected --> format all + }; + runTest(codeFormatter, "test700", "X.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 + public void test701() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.line_separator = "\n";//$NON-NLS-1$ + preferences.insert_new_line_after_annotation_on_parameter = true; + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(0, 221) // nothing selected --> format all + }; + runTest(codeFormatter, "test701", "X.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 + public void test702() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.line_separator = "\n";//$NON-NLS-1$ + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(0, 86) // nothing selected --> format all + }; + runTest(codeFormatter, "test702", "X.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 + public void test703() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.line_separator = "\n";//$NON-NLS-1$ + preferences.insert_new_line_after_annotation_on_parameter = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(0, 86) // nothing selected --> format all + }; + runTest(codeFormatter, "test703", "X.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 + public void test704() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.line_separator = "\n";//$NON-NLS-1$ + preferences.insert_new_line_after_annotation_on_type = false; + preferences.insert_new_line_after_annotation_on_field = false; + preferences.insert_new_line_after_annotation_on_method = false; + preferences.insert_new_line_after_annotation_on_package = false; + preferences.insert_new_line_after_annotation_on_parameter = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(0, 86) // nothing selected --> format all + }; + runTest(codeFormatter, "test704", "X.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 + public void test705() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.line_separator = "\n";//$NON-NLS-1$ + preferences.insert_new_line_after_annotation_on_type = false; + preferences.insert_new_line_after_annotation_on_field = false; + preferences.insert_new_line_after_annotation_on_method = false; + preferences.insert_new_line_after_annotation_on_package = false; + preferences.insert_new_line_after_annotation_on_parameter = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(0, 86) // nothing selected --> format all + }; + runTest(codeFormatter, "test705", "X.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 + // test706 through test712 format the same CU with different combination of annotation formatting options + public void test706() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.line_separator = "\n";//$NON-NLS-1$ + preferences.insert_new_line_after_annotation_on_type = false; + preferences.alignment_for_annotations_on_type = Alignment.M_NO_ALIGNMENT; + preferences.insert_new_line_after_annotation_on_field = false; + preferences.alignment_for_annotations_on_field = Alignment.M_NO_ALIGNMENT; + preferences.insert_new_line_after_annotation_on_method = false; + preferences.alignment_for_annotations_on_method = Alignment.M_NO_ALIGNMENT; + preferences.insert_new_line_after_annotation_on_package = false; + preferences.alignment_for_annotations_on_package = Alignment.M_NO_ALIGNMENT; + preferences.insert_new_line_after_annotation_on_parameter = true; + preferences.insert_new_line_after_annotation_on_local_variable = false; + preferences.alignment_for_annotations_on_local_variable = Alignment.M_NO_ALIGNMENT; + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test706", "X.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 + public void test707() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.insert_new_line_after_annotation_on_type = true; + preferences.insert_new_line_after_annotation_on_field = true; + preferences.insert_new_line_after_annotation_on_method = true; + preferences.insert_new_line_after_annotation_on_package = true; + preferences.insert_new_line_after_annotation_on_parameter = true; + preferences.insert_new_line_after_annotation_on_local_variable = false; + preferences.alignment_for_annotations_on_local_variable = Alignment.M_NO_ALIGNMENT; + preferences.line_separator = "\n";//$NON-NLS-1$ + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test707", "X.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 + public void test708() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.line_separator = "\n";//$NON-NLS-1$ + preferences.insert_new_line_after_annotation_on_type = true; + preferences.insert_new_line_after_annotation_on_field = true; + preferences.insert_new_line_after_annotation_on_method = true; + preferences.insert_new_line_after_annotation_on_package = true; + preferences.insert_new_line_after_annotation_on_parameter = false; + preferences.insert_new_line_after_annotation_on_local_variable = false; + preferences.alignment_for_annotations_on_local_variable = Alignment.M_NO_ALIGNMENT; + setPageWidth80(preferences); + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test708", "X.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 + public void test709() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.insert_new_line_after_annotation_on_type = false; + preferences.alignment_for_annotations_on_type = Alignment.M_NO_ALIGNMENT; + preferences.insert_new_line_after_annotation_on_field = false; + preferences.alignment_for_annotations_on_field = Alignment.M_NO_ALIGNMENT; + preferences.insert_new_line_after_annotation_on_method = false; + preferences.alignment_for_annotations_on_method = Alignment.M_NO_ALIGNMENT; + preferences.insert_new_line_after_annotation_on_package = false; + preferences.alignment_for_annotations_on_package = Alignment.M_NO_ALIGNMENT; + preferences.insert_new_line_after_annotation_on_parameter = false; + preferences.insert_new_line_after_annotation_on_local_variable = false; + preferences.alignment_for_annotations_on_local_variable = Alignment.M_NO_ALIGNMENT; + preferences.line_separator = "\n";//$NON-NLS-1$ + setPageWidth80(preferences); + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test709", "X.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 + public void test710() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.insert_new_line_after_annotation_on_type = false; + preferences.alignment_for_annotations_on_type = Alignment.M_NO_ALIGNMENT; + preferences.insert_new_line_after_annotation_on_field = false; + preferences.alignment_for_annotations_on_field = Alignment.M_NO_ALIGNMENT; + preferences.insert_new_line_after_annotation_on_method = false; + preferences.alignment_for_annotations_on_method = Alignment.M_NO_ALIGNMENT; + preferences.insert_new_line_after_annotation_on_package = false; + preferences.alignment_for_annotations_on_package = Alignment.M_NO_ALIGNMENT; + preferences.insert_new_line_after_annotation_on_parameter = true; + preferences.insert_new_line_after_annotation_on_local_variable = true; + preferences.line_separator = "\n";//$NON-NLS-1$ + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test710", "X.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 + public void test711() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.insert_new_line_after_annotation_on_type = false; + preferences.alignment_for_annotations_on_type = Alignment.M_NO_ALIGNMENT; + preferences.insert_new_line_after_annotation_on_field = false; + preferences.alignment_for_annotations_on_field = Alignment.M_NO_ALIGNMENT; + preferences.insert_new_line_after_annotation_on_method = false; + preferences.alignment_for_annotations_on_method = Alignment.M_NO_ALIGNMENT; + preferences.insert_new_line_after_annotation_on_package = false; + preferences.alignment_for_annotations_on_package = Alignment.M_NO_ALIGNMENT; + preferences.insert_new_line_after_annotation_on_parameter = false; + preferences.insert_new_line_after_annotation_on_local_variable = true; + preferences.line_separator = "\n";//$NON-NLS-1$ + setPageWidth80(preferences); + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test711", "X.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 + public void test712() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.line_separator = "\n";//$NON-NLS-1$ + setPageWidth80(preferences); + // use defaults + Hashtable javaCoreOptions = JavaCore.getOptions(); + try { + Hashtable newJavaCoreOptions = JavaCore.getOptions(); + newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + JavaCore.setOptions(newJavaCoreOptions); + + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test712", "X.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } finally { + JavaCore.setOptions(javaCoreOptions); + } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=222182 + public void test713() { + String resourcePath = getResource("test713", "formatter.xml"); + Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "Dani"); + assertNotNull("No preferences", options); + /* old version + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test713", "A.java", CodeFormatter.K_COMPILATION_UNIT, 0, false, 76, 27);//$NON-NLS-1$ //$NON-NLS-2$ + */ + this.formatterPrefs = new DefaultCodeFormatterOptions(options); + String source = + "package pack;\n" + + "\n" + + "public class A {\n" + + " /**\n" + + " * @see A.Inner\n" + + " */\n" + + "[# public class Inner { }\n" + + "#]}"; + formatSource(source, + "package pack;\n" + + "\n" + + "public class A {\n" + + " /**\n" + + " * @see A.Inner\n" + + " */\n" + + " public class Inner {\n" + + " }\n" + + "}" + ); + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=102780 + public void test714() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + // verify that the javadoc is indented, though the formatting of javadoc comments is disabled + preferences.comment_format_javadoc_comment = false; + setPageWidth80(preferences); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test714", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=244477 + public void test715() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.keep_empty_array_initializer_on_one_line = true; + preferences.insert_space_before_comma_in_array_initializer = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test715", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=244477 + public void test716() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.keep_empty_array_initializer_on_one_line = true; + preferences.insert_space_before_comma_in_array_initializer = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test716", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=244477 + public void test717() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.keep_empty_array_initializer_on_one_line = false; + preferences.insert_space_before_comma_in_array_initializer = false; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test717", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=244477 + public void test718() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.keep_empty_array_initializer_on_one_line = false; + preferences.insert_space_before_comma_in_array_initializer = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test718", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=250753 + public void test719() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + preferences.keep_empty_array_initializer_on_one_line = false; + preferences.insert_space_between_empty_braces_in_array_initializer = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + runTest(codeFormatter, "test719", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ + } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=270983 +public void test720() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test720", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=270983 +public void test721() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test721", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=283133 +public void test722() { + try { + assertEquals("Should be 0", 0, IndentManipulation.measureIndentUnits("", 1, 0)); + } catch (IllegalArgumentException e) { + assertTrue("Should not happen", false); + } +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=284679 +public void test723() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + Map compilerOptions = new HashMap(); + compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); + runTest(codeFormatter, "test723", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=150741 +public void test724() { + this.formatterPrefs.insert_new_line_after_label = true; + String source = + "public class X {\n" + + " public static void main(String[] args) {\n" + + " LABEL:for (int i = 0; i < 10; i++) {\n" + + " }\n" + + " }\n" + + "\n" + + "}\n" + + ""; + formatSource(source, + "public class X {\n" + + " public static void main(String[] args) {\n" + + " LABEL:\n" + + " for (int i = 0; i < 10; i++) {\n" + + " }\n" + + " }\n" + + "\n" + + "}\n" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=308000 +public void test725() { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6); + String source = + "@Deprecated package pack;\n" + + "public class Test {\n" + + " @Deprecated Test(String s) {}\n" + + " @Deprecated String label;\n" + + " @Deprecated void foo() {}\n" + + " @Deprecated interface I {}\n" + + "}\n"; + formatSource(source, + "@Deprecated\n" + + "package pack;\n" + + "\n" + + "public class Test {\n" + + " @Deprecated\n" + + " Test(String s) {\n" + + " }\n" + + "\n" + + " @Deprecated\n" + + " String label;\n" + + "\n" + + " @Deprecated\n" + + " void foo() {\n" + + " }\n" + + "\n" + + " @Deprecated\n" + + " interface I {\n" + + " }\n" + + "}\n" + ); +} +public void test726() { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE, DefaultCodeFormatterConstants.FALSE); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD, DefaultCodeFormatterConstants.FALSE); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD, DefaultCodeFormatterConstants.FALSE); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE, DefaultCodeFormatterConstants.FALSE); + String source = + "@Deprecated package pack;\n" + + "public class Test {\n" + + " @Deprecated Test(String s) {}\n" + + " @Deprecated String label;\n" + + " @Deprecated void foo() {}\n" + + " @Deprecated interface I {}\n" + + "}\n"; + formatSource(source, + "@Deprecated package pack;\n" + + "\n" + + "public class Test {\n" + + " @Deprecated Test(String s) {\n" + + " }\n" + + "\n" + + " @Deprecated String label;\n" + + "\n" + + " @Deprecated void foo() {\n" + + " }\n" + + "\n" + + " @Deprecated interface I {\n" + + " }\n" + + "}\n" + ); +} +/** + * @deprecated Use a deprecated formatter option. + */ +public void test727() { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, DefaultCodeFormatterConstants.TRUE); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD, DefaultCodeFormatterConstants.FALSE); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD, DefaultCodeFormatterConstants.FALSE); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE, DefaultCodeFormatterConstants.FALSE); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE, DefaultCodeFormatterConstants.FALSE); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER, DefaultCodeFormatterConstants.FALSE); + String source = + "@Deprecated package pack;\n" + + "public class Test {\n" + + " @Deprecated Test(String s) {}\n" + + " @Deprecated String label;\n" + + " @Deprecated void foo() {}\n" + + " @Deprecated interface I {}\n" + + "}\n"; + formatSource(source, + "@Deprecated package pack;\n" + + "\n" + + "public class Test {\n" + + " @Deprecated Test(String s) {\n" + + " }\n" + + "\n" + + " @Deprecated String label;\n" + + "\n" + + " @Deprecated void foo() {\n" + + " }\n" + + "\n" + + " @Deprecated interface I {\n" + + " }\n" + + "}\n" + ); +} + +/** + * @deprecated Use a deprecated formatter option. + */ +public void test728() { + this.formatterPrefs = null; + this.formatterOptions.remove(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_ENUM_CONSTANT); + this.formatterOptions.remove(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD); + this.formatterOptions.remove(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD); + this.formatterOptions.remove(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE); + this.formatterOptions.remove(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE); + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION, DefaultCodeFormatterConstants.FALSE); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER, JavaCore.DO_NOT_INSERT); + String source = + "@Deprecated package pack;\n" + + "public class Test {\n" + + " @Deprecated Test(String s) {}\n" + + " @Deprecated String label;\n" + + " @Deprecated void foo() {}\n" + + " @Deprecated interface I {}\n" + + "}\n"; + formatSource(source, + "@Deprecated package pack;\n" + + "\n" + + "public class Test {\n" + + " @Deprecated Test(String s) {\n" + + " }\n" + + "\n" + + " @Deprecated String label;\n" + + "\n" + + " @Deprecated void foo() {\n" + + " }\n" + + "\n" + + " @Deprecated interface I {\n" + + " }\n" + + "}\n" + ); +} +public void test729() { + this.formatterPrefs = null; + String profilePath = getResource("profiles", "b308000.xml"); + this.formatterOptions = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(profilePath, "b308000"); + assertNotNull("No preferences", this.formatterOptions); + String source = + "package p;\n" + + "\n" + + "@Deprecated public class C {\n" + + " @Deprecated public static void main(@Deprecated String[] args) {\n" + + " @Deprecated int i= 2;\n" + + " System.out.println(i);\n" + + " }\n" + + "}\n"; + formatSource(source, + "package p;\n" + + "\n" + + "@Deprecated public class C {\n" + + " @Deprecated public static void main(@Deprecated String[] args) {\n" + + " @Deprecated\n" + + " int i = 2;\n" + + " System.out.println(i);\n" + + " }\n" + + "}\n" + ); +} +public void test730() { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + String source = "enum Fail1 {A;;{}}"; + formatSource( + source, + "enum Fail1 {\n" + + " A;\n" + + " ;\n" + + "\n" + + " {\n" + + " }\n" + + "}" + ); +} +public void test731() { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + String source = "enum Fail2 {A,B;;{}}"; + formatSource( + source, + "enum Fail2 {\n" + + " A, B;\n" + + " ;\n" + + "\n" + + " {\n" + + " }\n" + + "}" + ); +} +public void test732() { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + String source = "enum Fail3 {A;;public void foo() {}}"; + formatSource( + source, + "enum Fail3 {\n" + + " A;\n" + + " ;\n" + + "\n" + + " public void foo() {\n" + + " }\n" + + "}" + ); +} +public void test733() { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + String source = "enum Fail4 {A;;public int i = 0;}"; + formatSource( + source, + "enum Fail4 {\n" + + " A;\n" + + " ;\n" + + "\n" + + " public int i = 0;\n" + + "}" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=282988 +public void test734() { + this.formatterPrefs = null; + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_PRESERVE_WHITE_SPACE_BETWEEN_CODE_AND_LINE_COMMENT, DefaultCodeFormatterConstants.TRUE); + String source = + "package p;\n" + + "\n" + + "public class Comment {\n" + + " public static void main(String[] args) {\n" + + " // internal indentation\n" + + " int i = 1; // tabs\n" + + " int j = 2; // spaces\n" + + " int k = 3; // mixed tabs and spaces\n" + + " System.out.print(i); /* does not affect block comments */\n" + + " }\n" + + "}\n"; + formatSource(source, + "package p;\n" + + "\n" + + "public class Comment {\n" + + " public static void main(String[] args) {\n" + + " // internal indentation\n" + + " int i = 1; // tabs\n" + + " int j = 2; // spaces\n" + + " int k = 3; // mixed tabs and spaces\n" + + " System.out.print(i); /* does not affect block comments */\n" + + " }\n" + + "}\n" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=282988 +public void test735() { + this.formatterPrefs = null; + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_PRESERVE_WHITE_SPACE_BETWEEN_CODE_AND_LINE_COMMENT, DefaultCodeFormatterConstants.FALSE); + String source = + "package p;\n" + + "\n" + + "public class Comment {\n" + + " public static void main(String[] args) {\n" + + " // internal indentation\n" + + " int i = 1; // tabs\n" + + " int j = 2; // spaces\n" + + " int k = 3; // mixed tabs and spaces\n" + + " System.out.print(i); /* does not affect block comments */\n" + + " }\n" + + "}\n"; + formatSource(source, + "package p;\n" + + "\n" + + "public class Comment {\n" + + " public static void main(String[] args) {\n" + + " // internal indentation\n" + + " int i = 1; // tabs\n" + + " int j = 2; // spaces\n" + + " int k = 3; // mixed tabs and spaces\n" + + " System.out.print(i); /* does not affect block comments */\n" + + " }\n" + + "}\n" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=282988 +public void test736() { + this.formatterPrefs = null; + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_PRESERVE_WHITE_SPACE_BETWEEN_CODE_AND_LINE_COMMENT, DefaultCodeFormatterConstants.TRUE); + String source = + "package p;\n" + + "\n" + + "public class Comment {\n" + + " public static void main(String[] args) {\n" + + " // internal indentation\n" + + " int i = 1;// tabs\n" + + " int j = 2;// spaces\n" + + " int k = 3;// mixed tabs and spaces\n" + + " System.out.print(i); /* does not affect block comments */\n" + + " }\n" + + "}\n"; + formatSource(source, + "package p;\n" + + "\n" + + "public class Comment {\n" + + " public static void main(String[] args) {\n" + + " // internal indentation\n" + + " int i = 1;// tabs\n" + + " int j = 2;// spaces\n" + + " int k = 3;// mixed tabs and spaces\n" + + " System.out.print(i); /* does not affect block comments */\n" + + " }\n" + + "}\n" + ); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=282988 +public void test737() { + this.formatterPrefs = null; + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_PRESERVE_WHITE_SPACE_BETWEEN_CODE_AND_LINE_COMMENT, DefaultCodeFormatterConstants.FALSE); + String source = + "package p;\n" + + "\n" + + "public class Comment {\n" + + " public static void main(String[] args) {\n" + + " // internal indentation\n" + + " int i = 1;// tabs\n" + + " int j = 2;// spaces\n" + + " int k = 3;// mixed tabs and spaces\n" + + " System.out.print(i); /* does not affect block comments */\n" + + " }\n" + + "}\n"; + formatSource(source, + "package p;\n" + + "\n" + + "public class Comment {\n" + + " public static void main(String[] args) {\n" + + " // internal indentation\n" + + " int i = 1;// tabs\n" + + " int j = 2;// spaces\n" + + " int k = 3;// mixed tabs and spaces\n" + + " System.out.print(i); /* does not affect block comments */\n" + + " }\n" + + "}\n" + ); +} +// binary literals / underscores in literals / multi catch +public void test738() { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + String source = + "public class Test {\n" + + " int i = 0b0001;\n" + + " int j = 0b0_0_0_1;\n" + + " void foo(String s) {\n" + + " try {\n" + + " FileReader reader = new FileReader(s);\n" + + " } catch(FileNotFoundException | IOException | Exception e) {\n" + + " e.printStackTrace();\n" + + " }\n" + + " }\n" + + "}\n"; + formatSource(source, + "public class Test {\n" + + " int i = 0b0001;\n" + + " int j = 0b0_0_0_1;\n" + + "\n" + + " void foo(String s) {\n" + + " try {\n" + + " FileReader reader = new FileReader(s);\n" + + " } catch (FileNotFoundException | IOException | Exception e) {\n" + + " e.printStackTrace();\n" + + " }\n" + + " }\n" + + "}\n" + ); +} +//try-with-resources +public void test739() { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + String source = + "public class Test {\n" + + " void foo(String s) {\n" + + " try (FileReader reader = new FileReader(s)) {\n" + + " reader.read();\n" + + " } catch(IOException e) {\n" + + " e.printStackTrace();\n" + + " }\n" + + " }\n" + + "}\n"; + formatSource(source, + "public class Test {\n" + + " void foo(String s) {\n" + + " try (FileReader reader = new FileReader(s)) {\n" + + " reader.read();\n" + + " } catch (IOException e) {\n" + + " e.printStackTrace();\n" + + " }\n" + + " }\n" + + "}\n" + ); +} +//try-with-resources +public void test740() { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + String source = + "public class Test {\n" + + " void foo(String s) {\n" + + " try (FileReader reader = new FileReader(s)) {\n" + + " reader.read();\n" + + " } catch(IOException e) {\n" + + " e.printStackTrace();\n" + + " }\n" + + " }\n" + + "}\n"; + formatSource(source, + "public class Test {\n" + + " void foo(String s) {\n" + + " try (FileReader reader = new FileReader(s)) {\n" + + " reader.read();\n" + + " } catch (IOException e) {\n" + + " e.printStackTrace();\n" + + " }\n" + + " }\n" + + "}\n" + ); +} +//try-with-resources +public void test741() { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + String source = + "public class Test {\n" + + " void foo(String s) {\n" + + " try (FileReader reader = new FileReader(s)) {\n" + + " reader.read();\n" + + " } catch(IOException e) {\n" + + " e.printStackTrace();\n" + + " } finally {\n" + + " System.out.println(\"finally block\");\n" + + " }\n" + + " }\n" + + "}\n"; + formatSource(source, + "public class Test {\n" + + " void foo(String s) {\n" + + " try (FileReader reader = new FileReader(s)) {\n" + + " reader.read();\n" + + " } catch (IOException e) {\n" + + " e.printStackTrace();\n" + + " } finally {\n" + + " System.out.println(\"finally block\");\n" + + " }\n" + + " }\n" + + "}\n" + ); +} +//try-with-resources +public void test742() { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + String source = + "public class Test {\n" + + " void foo(String s) {\n" + + " try (FileReader reader = new FileReader(s)) {\n" + + " reader.read();\n" + + " } catch(FileNotFoundException | IOException | Exception e) {\n" + + " e.printStackTrace();\n" + + " } finally {\n" + + " System.out.println(\"finally block\");\n" + + " }\n" + + " }\n" + + "}\n"; + formatSource(source, + "public class Test {\n" + + " void foo(String s) {\n" + + " try (FileReader reader = new FileReader(s)) {\n" + + " reader.read();\n" + + " } catch (FileNotFoundException | IOException | Exception e) {\n" + + " e.printStackTrace();\n" + + " } finally {\n" + + " System.out.println(\"finally block\");\n" + + " }\n" + + " }\n" + + "}\n" + ); +} +//try-with-resources +public void test743() { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + String source = + "public class Test {\n" + + " void foo(String s) {\n" + + " try (FileReader reader = new FileReader(s);) {\n" + + " reader.read();\n" + + " } catch(FileNotFoundException | IOException | Exception e) {\n" + + " e.printStackTrace();\n" + + " } finally {\n" + + " System.out.println(\"finally block\");\n" + + " }\n" + + " }\n" + + "}\n"; + formatSource(source, + "public class Test {\n" + + " void foo(String s) {\n" + + " try (FileReader reader = new FileReader(s);) {\n" + + " reader.read();\n" + + " } catch (FileNotFoundException | IOException | Exception e) {\n" + + " e.printStackTrace();\n" + + " } finally {\n" + + " System.out.println(\"finally block\");\n" + + " }\n" + + " }\n" + + "}\n" + ); +} +//try-with-resources +public void test744() { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + setFormatterOptions80(); + String source = + "public class Test {\n" + + " void foo(String s) {\n" + + " try (FileReader reader = new FileReader(s);FileReader reader2 = new FileReader(s)) {\n" + + " reader.read();\n" + + " reader2.read();\n" + + " } catch(FileNotFoundException | IOException | Exception e) {\n" + + " e.printStackTrace();\n" + + " } finally {\n" + + " System.out.println(\"finally block\");\n" + + " }\n" + + " }\n" + + "}\n"; + formatSource(source, + "public class Test {\n" + + " void foo(String s) {\n" + + " try (FileReader reader = new FileReader(s);\n" + + " FileReader reader2 = new FileReader(s)) {\n" + + " reader.read();\n" + + " reader2.read();\n" + + " } catch (FileNotFoundException | IOException | Exception e) {\n" + + " e.printStackTrace();\n" + + " } finally {\n" + + " System.out.println(\"finally block\");\n" + + " }\n" + + " }\n" + + "}\n" + ); +} +//try-with-resources +public void test745() { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + setFormatterOptions80(); + String source = + "public class Test {\n" + + " void foo(String s) {\n" + + " try (FileReader reader = new FileReader(s);FileReader reader2 = new FileReader(s);) {\n" + + " reader.read();\n" + + " reader2.read();\n" + + " } catch(FileNotFoundException | IOException | Exception e) {\n" + + " e.printStackTrace();\n" + + " } finally {\n" + + " System.out.println(\"finally block\");\n" + + " }\n" + + " }\n" + + "}\n"; + formatSource(source, + "public class Test {\n" + + " void foo(String s) {\n" + + " try (FileReader reader = new FileReader(s);\n" + + " FileReader reader2 = new FileReader(s);) {\n" + + " reader.read();\n" + + " reader2.read();\n" + + " } catch (FileNotFoundException | IOException | Exception e) {\n" + + " e.printStackTrace();\n" + + " } finally {\n" + + " System.out.println(\"finally block\");\n" + + " }\n" + + " }\n" + + "}\n" + ); +} +//diamond +public void test746() { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + String source = + "public class Test {\n" + + " List foo(String s) {\n" + + " List l = new ArrayList<>();\n" + + " l.add(s);\n" + + " return l;\n" + + " }\n" + + "}\n"; + formatSource(source, + "public class Test {\n" + + " List foo(String s) {\n" + + " List l = new ArrayList<>();\n" + + " l.add(s);\n" + + " return l;\n" + + " }\n" + + "}\n" + ); +} +//diamond +public void test747() { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + String source = + "public class Test {\n" + + " List foo(String s) {\n" + + " List l = new java.util.ArrayList<>();\n" + + " l.add(s);\n" + + " return l;\n" + + " }\n" + + "}\n"; + formatSource(source, + "public class Test {\n" + + " List foo(String s) {\n" + + " List l = new java.util.ArrayList<>();\n" + + " l.add(s);\n" + + " return l;\n" + + " }\n" + + "}\n" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=335309 +public void test748() { + final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); + DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); + IRegion[] regions = new IRegion[] { + new Region(705, 0) + }; + runTest(codeFormatter, "test748", "RecipeDocumentProvider.java", CodeFormatter.K_COMPILATION_UNIT, 0, true, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349008 +public void test749() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try (FileReader fis = new FileReader(s); FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s)) {\n" + + " }\n" + + " }\n" + + "}\n"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try (FileReader fis = new FileReader(s);\n" + + " FileReader fis2 = new FileReader(s);\n" + + " FileReader fis3 = new FileReader(s)) {\n" + + " }\n" + + " }\n" + + "}\n" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 +// To verify that the whitespace options for resources in try statement work correctly +public void test750() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_TRY, JavaCore.DO_NOT_INSERT); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_TRY, JavaCore.INSERT); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_TRY, JavaCore.INSERT); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_TRY_RESOURCES, JavaCore.INSERT); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try( FileReader fis = new FileReader(s) ;\n" + + " FileReader fis2 = new FileReader(s) ;\n" + + " FileReader fis3 = new FileReader(s) ; ) {\n" + + " }\n" + + " }\n" + + "}\n" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 +// To check behavior with different line wrapping and indentation policies. +public void test751() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NO_SPLIT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + setFormatterOptions80(); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try (FileReader fis = new FileReader(\n" + + " s); FileReader fis2 = new FileReader(\n" + + " s); FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 +// To check behavior with different line wrapping and indentation policies. +public void test752() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try ( FileReader fis = new FileReader(s);\n" + + " FileReader fis2 = new FileReader(s);\n" + + " FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 +// To check behavior with different line wrapping and indentation policies. +public void test753() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_BY_ONE)); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try (FileReader fis = new FileReader(s);\n" + + " FileReader fis2 = new FileReader(s);\n" + + " FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 +// To check behavior with different line wrapping and indentation policies. +public void test754() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "120"); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try (FileReader fis = new FileReader(s); FileReader fis2 = new FileReader(s);\n" + + " FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 +// To check behavior with different line wrapping and indentation policies. +public void test755() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "120"); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try ( FileReader fis = new FileReader(s); FileReader fis2 = new FileReader(s);\n" + + " FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 +// To check behavior with different line wrapping and indentation policies. +public void test756() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_BY_ONE)); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "120"); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try (FileReader fis = new FileReader(s); FileReader fis2 = new FileReader(s);\n" + + " FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 +// To check behavior with different line wrapping and indentation policies. +public void test757() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT_FIRST_BREAK, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "120"); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try (\n" + + " FileReader fis = new FileReader(s); FileReader fis2 = new FileReader(s);\n" + + " FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 +// To check behavior with different line wrapping and indentation policies. +public void test758() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT_FIRST_BREAK, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "120"); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try (\n" + + " FileReader fis = new FileReader(s); FileReader fis2 = new FileReader(s);\n" + + " FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 +// To check behavior with different line wrapping and indentation policies. +public void test759() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT_FIRST_BREAK, DefaultCodeFormatterConstants.INDENT_BY_ONE)); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "120"); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try (\n" + + " FileReader fis = new FileReader(s); FileReader fis2 = new FileReader(s);\n" + + " FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 +// To check behavior with different line wrapping and indentation policies. +public void test760() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_SHIFTED, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "120"); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try (\n" + + " FileReader fis = new FileReader(s);\n" + + " FileReader fis2 = new FileReader(s);\n" + + " FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 +// To check behavior with different line wrapping and indentation policies. +public void test761() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_SHIFTED, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "120"); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try (\n" + + " FileReader fis = new FileReader(s);\n" + + " FileReader fis2 = new FileReader(s);\n" + + " FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 +// To check behavior with different line wrapping and indentation policies. +public void test762() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_SHIFTED, DefaultCodeFormatterConstants.INDENT_BY_ONE)); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "120"); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try (\n" + + " FileReader fis = new FileReader(s);\n" + + " FileReader fis2 = new FileReader(s);\n" + + " FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 +// To check behavior with different line wrapping and indentation policies. +public void test763() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "120"); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try (\n" + + " FileReader fis = new FileReader(s);\n" + + " FileReader fis2 = new FileReader(s);\n" + + " FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 +// To check behavior with different line wrapping and indentation policies. +public void test764() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_BY_ONE)); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "120"); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try (\n" + + " FileReader fis = new FileReader(s);\n" + + " FileReader fis2 = new FileReader(s);\n" + + " FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349396 +// To check behavior with different line wrapping and indentation policies. +public void test765() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "120"); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try( FileReader fis = new FileReader(s);FileReader fis2 = new FileReader(s); FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void storeSomething(String s) throws Exception {\n" + + " try (\n" + + " FileReader fis = new FileReader(s);\n" + + " FileReader fis2 = new FileReader(s);\n" + + " FileReader fis3 = new FileReader(s);) {\n" + + " }\n" + + " }\n" + + "}\n" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 +// To check behavior with different line wrapping and indentation policies. +public void test766() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NO_SPLIT, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try{\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "class MyE extends Exception {}"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try {\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE | FileNotFoundException | ArrayIndexOutOfBoundsException | IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "\n" + + "class MyE extends Exception {\n" + + "}" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 +// To check behavior with default settings. +public void test767() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + setFormatterOptions80(); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try{\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "class MyE extends Exception {}"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try {\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE | FileNotFoundException | ArrayIndexOutOfBoundsException\n" + + " | IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "\n" + + "class MyE extends Exception {\n" + + "}" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 +// To check behavior with default settings. +public void test767a() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "60"); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try{\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "class MyE extends Exception {}"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try {\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE | FileNotFoundException\n" + + " | ArrayIndexOutOfBoundsException\n" + + " | IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "\n" + + "class MyE extends Exception {\n" + + "}" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 +// To check behavior with default settings, and spaces before '|' and not after them. +public void test767b() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BITWISE_OPERATOR, JavaCore.INSERT); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_BITWISE_OPERATOR, JavaCore.DO_NOT_INSERT); + setFormatterOptions80(); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try{\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "class MyE extends Exception {}"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try {\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE |FileNotFoundException |ArrayIndexOutOfBoundsException\n" + + " |IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "\n" + + "class MyE extends Exception {\n" + + "}" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 +// To check behavior with different line wrapping and indentation policies. +public void test768() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + setFormatterOptions80(); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try{\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "class MyE extends Exception {}"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try {\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch ( MyE | FileNotFoundException | ArrayIndexOutOfBoundsException\n" + + " | IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "\n" + + "class MyE extends Exception {\n" + + "}" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 +// To check behavior with different line wrapping and indentation policies. +public void test769() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_BY_ONE)); + setFormatterOptions80(); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try{\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "class MyE extends Exception {}"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try {\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE | FileNotFoundException | ArrayIndexOutOfBoundsException\n" + + " | IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "\n" + + "class MyE extends Exception {\n" + + "}" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 +// To check behavior with different line wrapping and indentation policies. +public void test770() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT_FIRST_BREAK, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + setFormatterOptions80(); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try{\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "class MyE extends Exception {}"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try {\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (\n" + + " MyE | FileNotFoundException | ArrayIndexOutOfBoundsException\n" + + " | IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "\n" + + "class MyE extends Exception {\n" + + "}" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 +// To check behavior with different line wrapping and indentation policies. +public void test771() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT_FIRST_BREAK, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + setFormatterOptions80(); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try{\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "class MyE extends Exception {}"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try {\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (\n" + + " MyE | FileNotFoundException | ArrayIndexOutOfBoundsException\n" + + " | IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "\n" + + "class MyE extends Exception {\n" + + "}" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 +// To check behavior with different line wrapping and indentation policies. +public void test772() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT_FIRST_BREAK, DefaultCodeFormatterConstants.INDENT_BY_ONE)); + setFormatterOptions80(); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try{\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "class MyE extends Exception {}"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try {\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (\n" + + " MyE | FileNotFoundException | ArrayIndexOutOfBoundsException\n" + + " | IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "\n" + + "class MyE extends Exception {\n" + + "}" + ); +} + +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 +// To check behavior with different line wrapping and indentation policies. +public void test773() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + setFormatterOptions80(); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try{\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "class MyE extends Exception {}"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try {\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE\n" + + " | FileNotFoundException\n" + + " | ArrayIndexOutOfBoundsException\n" + + " | IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "\n" + + "class MyE extends Exception {\n" + + "}" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 +// To check behavior with different line wrapping and indentation policies. +public void test774() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + setFormatterOptions80(); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try{\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "class MyE extends Exception {}"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try {\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch ( MyE\n" + + " | FileNotFoundException\n" + + " | ArrayIndexOutOfBoundsException\n" + + " | IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "\n" + + "class MyE extends Exception {\n" + + "}" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 +// To check behavior with different line wrapping and indentation policies. +public void test775() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_BY_ONE)); + setFormatterOptions80(); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try{\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "class MyE extends Exception {}"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try {\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE\n" + + " | FileNotFoundException\n" + + " | ArrayIndexOutOfBoundsException\n" + + " | IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "\n" + + "class MyE extends Exception {\n" + + "}" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 +// To check behavior with different line wrapping and indentation policies. +public void test776() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_SHIFTED, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + setFormatterOptions80(); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try{\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "class MyE extends Exception {}"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try {\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (\n" + + " MyE\n" + + " | FileNotFoundException\n" + + " | ArrayIndexOutOfBoundsException\n" + + " | IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "\n" + + "class MyE extends Exception {\n" + + "}" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 +// To check behavior with different line wrapping and indentation policies. +public void test777() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_SHIFTED, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + setFormatterOptions80(); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try{\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "class MyE extends Exception {}"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try {\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (\n" + + " MyE\n" + + " | FileNotFoundException\n" + + " | ArrayIndexOutOfBoundsException\n" + + " | IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "\n" + + "class MyE extends Exception {\n" + + "}" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 +// To check behavior with different line wrapping and indentation policies. +public void test778() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NEXT_SHIFTED, DefaultCodeFormatterConstants.INDENT_BY_ONE)); + setFormatterOptions80(); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try{\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "class MyE extends Exception {}"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try {\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (\n" + + " MyE\n" + + " | FileNotFoundException\n" + + " | ArrayIndexOutOfBoundsException\n" + + " | IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "\n" + + "class MyE extends Exception {\n" + + "}" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 +// To check behavior with different line wrapping and indentation policies. +public void test779() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + setFormatterOptions80(); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try{\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "class MyE extends Exception {}"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try {\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (\n" + + " MyE\n" + + " | FileNotFoundException\n" + + " | ArrayIndexOutOfBoundsException\n" + + " | IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "\n" + + "class MyE extends Exception {\n" + + "}" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 +// To check behavior with different line wrapping and indentation policies. +public void test780() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + setFormatterOptions80(); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try{\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "class MyE extends Exception {}"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try {\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (\n" + + " MyE\n" + + " | FileNotFoundException\n" + + " | ArrayIndexOutOfBoundsException\n" + + " | IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "\n" + + "class MyE extends Exception {\n" + + "}" + ); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=349314 +//To check behavior with different line wrapping and indentation policies. +public void test781() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_BY_ONE)); + setFormatterOptions80(); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try{\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "class MyE extends Exception {}"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try {\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (\n" + + " MyE\n" + + " | FileNotFoundException\n" + + " | ArrayIndexOutOfBoundsException\n" + + " | IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "\n" + + "class MyE extends Exception {\n" + + "}" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=350895 +// To check behavior with default settings and wrap before '|' operator disabled. +public void test782() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_WRAP_BEFORE_OR_OPERATOR_MULTICATCH, JavaCore.DISABLED); + setFormatterOptions80(); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try{\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE| FileNotFoundException| ArrayIndexOutOfBoundsException| IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "class MyE extends Exception {}"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " public void foo(boolean a) {\n" + + " try {\n" + + " if (a)\n" + + " throw new FileNotFoundException();\n" + + " else\n" + + " throw new MyE();\n" + + " } catch (MyE | FileNotFoundException | ArrayIndexOutOfBoundsException |\n" + + " IllegalArgumentException ex) {\n" + + " }\n" + + " }\n" + + "}\n" + + "\n" + + "class MyE extends Exception {\n" + + "}" + ); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=359646 +public void test783() throws Exception { + this.formatterPrefs = null; + String source = + "public class X {public static void main(String[] args) {\n" + + " long x = 0x8000000000000000L;\n" + + " System.out.println(x);\n" + + " }\n" + + "}"; + formatSource(source, + "public class X {\n" + + " public static void main(String[] args) {\n" + + " long x = 0x8000000000000000L;\n" + + " System.out.println(x);\n" + + " }\n" + + "}" + ); +} + +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=379793 +// To verify that the whitespace options for resources in try statement work correctly +public void testBug379793() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "80"); + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_TRY, JavaCore.INSERT); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_TRY_RESOURCES, JavaCore.INSERT); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION, "1"); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "2"); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, "2"); + this.formatterOptions.put( + DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); + String source = + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " void jbtnJDBCTest_actionPerformed(final ActionEvent e) {\n" + + " if ((driverClasses != null) && (JDBCURL != null)) {\n" + + " if (test == true) {\n" + + " try (final Connection connection = DriverManager.getConnection(JDBCURL);) {\n" + + " test = (connection != null);\n" + + " if (test == true) {\n" + + " jTextArea1.setText(\"The test was completeted successfully!\");\n" + + " }\n" + + " } catch (final SQLException sx) {\n" + + " jTextArea1\n" + + " .setText(\"\");\n" + + " }\n" + + " }\n" + + " }\n" + + " }\n" + + "}\n"; + formatSource(source, + "package test;\n" + + "\n" + + "public class FormatterError {\n" + + " void jbtnJDBCTest_actionPerformed(final ActionEvent e) {\n" + + " if ((driverClasses != null) && (JDBCURL != null)) {\n" + + " if (test == true) {\n" + + " try (\n" + + " final Connection connection = DriverManager.getConnection(JDBCURL);) {\n" + + " test = (connection != null);\n" + + " if (test == true) {\n" + + " jTextArea1.setText(\"The test was completeted successfully!\");\n" + + " }\n" + + " } catch (final SQLException sx) {\n" + + " jTextArea1.setText(\"\");\n" + + " }\n" + + " }\n" + + " }\n" + + " }\n" + + "}\n" + ); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=405038 +//To verify that the whitespace options for resources in try statement work correctly +public void testBug405038() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ADDITIVE_OPERATOR, JavaCore.DO_NOT_INSERT); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ADDITIVE_OPERATOR, JavaCore.DO_NOT_INSERT); + String source = + "public class FormatterError {\n" + + " int foo(int a, int b, int c) {\n" + + " return a + b + ++c;\n" + + " }\n" + + "}\n"; + formatSource(source, + "public class FormatterError {\n" + + " int foo(int a, int b, int c) {\n" + + " return a+b+ ++c;\n" + + " }\n" + + "}\n" + ); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=405038 +//To verify that the whitespace options for resources in try statement work correctly +public void testBug405038_2() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ADDITIVE_OPERATOR, JavaCore.DO_NOT_INSERT); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ADDITIVE_OPERATOR, JavaCore.DO_NOT_INSERT); + String source = + "public class FormatterError {\n" + + " int foo(int a, int b, int c) {\n" + + " return a + ++b + c;\n" + + " }\n" + + "}\n"; + formatSource(source, + "public class FormatterError {\n" + + " int foo(int a, int b, int c) {\n" + + " return a+ ++b+c;\n" + + " }\n" + + "}\n" + ); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=405038 +//To verify that the whitespace options for resources in try statement work correctly +public void testBug405038_3() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ADDITIVE_OPERATOR, JavaCore.DO_NOT_INSERT); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ADDITIVE_OPERATOR, JavaCore.DO_NOT_INSERT); + String source = + "public class FormatterError {\n" + + " int foo(int a, int b, int c) {\n" + + " return a - --b + c;\n" + + " }\n" + + "}\n"; + formatSource(source, + "public class FormatterError {\n" + + " int foo(int a, int b, int c) {\n" + + " return a- --b+c;\n" + + " }\n" + + "}\n" + ); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=405038 +//To verify that the whitespace options for resources in try statement work correctly +public void testBug405038_4() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ADDITIVE_OPERATOR, JavaCore.DO_NOT_INSERT); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ADDITIVE_OPERATOR, JavaCore.DO_NOT_INSERT); + String source = + "public class FormatterError {\n" + + " int foo(int a, int b, int c) {\n" + + " return a - -b + c;\n" + + " }\n" + + "}\n"; + formatSource(source, + "public class FormatterError {\n" + + " int foo(int a, int b, int c) {\n" + + " return a- -b+c;\n" + + " }\n" + + "}\n" + ); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=405038 +//To verify that the whitespace options for resources in try statement work correctly +public void testBug405038_5() throws Exception { + this.formatterPrefs = null; + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ADDITIVE_OPERATOR, JavaCore.DO_NOT_INSERT); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ADDITIVE_OPERATOR, JavaCore.DO_NOT_INSERT); + String source = + "public class FormatterError {\n" + + " int foo(int a, int b, int c) {\n" + + " return a - -b + ++c;\n" + + " }\n" + + "}\n"; + formatSource(source, + "public class FormatterError {\n" + + " int foo(int a, int b, int c) {\n" + + " return a- -b+ ++c;\n" + + " }\n" + + "}\n" + ); +} + +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=432593 +public void testBug432593() throws IOException { + ICompilationUnit sourceUnit; + try { + sourceUnit = getCompilationUnit("Formatter" , "", "test432593", getIn("A.java")); + String src = sourceUnit.getSource(); + assertNotNull(src); + String source = src.toString(); + final Map options = JavaCore.getOptions(); + options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); + options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); + options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); + final CodeFormatter codeFormatter = ToolFactory.createCodeFormatter(options); + final TextEdit edit = codeFormatter.format(CodeFormatter.K_COMPILATION_UNIT, source, 0, source.length(), 0, "\r\n"); + assertTrue(edit != null); + } catch (JavaModelException e) { + e.printStackTrace(); + } +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=467229 +public void testBug467229() throws IOException { + final Map optionsMap = JavaCore.getOptions(); + int tabSize = 3; + int indentSize = 5; + String[] keysToCheck = { + DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, + DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE }; + + optionsMap.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, tabSize + ""); + optionsMap.put(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, indentSize + ""); + + /* compare with org.eclipse.jdt.internal.ui.preferences.formatter.IndentationTabPage.updateTabPreferences() */ + optionsMap.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, DefaultCodeFormatterConstants.MIXED); + DefaultCodeFormatterOptions options = new DefaultCodeFormatterOptions(optionsMap); + assertEquals(tabSize, options.tab_size); + assertEquals(indentSize, options.indentation_size); + Map optionsMap2 = options.getMap(); + for (String key : keysToCheck) { + assertEquals(key, optionsMap.get(key), optionsMap2.get(key)); + } + + optionsMap.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); + options.set(optionsMap); + assertEquals(indentSize, options.tab_size); + assertEquals(tabSize, options.indentation_size); + optionsMap2 = options.getMap(); + for (String key : keysToCheck) { + assertEquals(key, optionsMap.get(key), optionsMap2.get(key)); + } + + optionsMap.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + options.set(optionsMap); + assertEquals(tabSize, options.tab_size); + assertEquals(tabSize, options.indentation_size); + optionsMap2 = options.getMap(); + String key = keysToCheck[0]; // the other is lost in this conversion + assertEquals(key, optionsMap.get(key), optionsMap2.get(key)); +} +/** + * https://bugs.eclipse.org/477476 - Auto-formatter gets indentation wrong when used as post-save action + */ +public void testBug477476a() { + setComplianceLevel(CompilerOptions.VERSION_1_5); + this.formatterPrefs.use_tabs_only_for_leading_indentations = true; + runTest(codeFormatter(), "test477476a", "A.java", CodeFormatter.K_COMPILATION_UNIT, false); +} +/** + * https://bugs.eclipse.org/477476 - Auto-formatter gets indentation wrong when used as post-save action + */ +public void testBug477476b() { + setComplianceLevel(CompilerOptions.VERSION_1_5); + try { + String input = getCompilationUnit("Formatter" , "", "test477476b", "A_in.java").getSource(); + String output = getCompilationUnit("Formatter" , "", "test477476b", "A_out.java").getSource(); + formatSource(input, output); + } catch (JavaModelException e) { + e.printStackTrace(); + assertTrue(false); + } +} +/** + * https://bugs.eclipse.org/485495 - [Formatter] does not insert space before semicolon at the end of the statement + */ +public void testBug485495() { + this.formatterPrefs.insert_space_before_semicolon = true; + String source = + "package test ;\n" + + "\n" + + "import java.util.ArrayList ;\n" + + "\n" + + "public class Test {\n" + + "\n" + + " interface I {\n" + + " void method() ;\n" + + " }\n" + + "\n" + + " ArrayList e = null ;\n" + + " int i ;\n" + + "\n" + + " void foo() {\n" + + " int i = 0 ;\n" + + " String s ;\n" + + " if (i > 0)\n" + + " return ;\n" + + " for (int j = 0; j < 5; j++) {\n" + + " Object o ;\n" + + " while (i < 0)\n" + + " o = new Object() {\n" + + " int f ;\n" + + "\n" + + " void bar() {\n" + + " if (f > 0)\n" + + " f = 5 ;\n" + + " else\n" + + " f = 16 ;\n" + + " try {\n" + + " f = 14 ;\n" + + " } catch (Exception e) {\n" + + " bar() ;\n" + + " }\n" + + " }\n" + + " } ;\n" + + " while (i < 0)\n" + + " switch (i) {\n" + + " case 4:\n" + + " foo() ;\n" + + " }\n" + + " }\n" + + " }\n" + + "}"; + formatSource(source); +} +/** + * https://bugs.eclipse.org/479109 - [formatter] Add option to group aligned fields with blank lines + */ +public void testBug479109a() { + this.formatterPrefs.align_type_members_on_columns = true; + this.formatterPrefs.align_fields_grouping_blank_lines = 1; + String source = + "public class Test {\n" + + " String field1 = \"1\"; //\n" + + "\n" + + " public String field2 = \"2222\"; //\n" + + "\n" + + "\n" + + " protected final String field3 = \"333333333\"; //\n" + + "}"; + formatSource(source, + "public class Test {\n" + + " String field1 = \"1\"; //\n" + + "\n" + + " public String field2 = \"2222\"; //\n" + + "\n" + + " protected final String field3 = \"333333333\"; //\n" + + "}" + ); +} +/** + * https://bugs.eclipse.org/479109 - [formatter] Add option to group aligned fields with blank lines + */ +public void testBug479109b() { + this.formatterPrefs.align_type_members_on_columns = true; + this.formatterPrefs.align_fields_grouping_blank_lines = 2; + String source = + "public class Test {\n" + + " String field1 = \"1\";\n" + + "\n" + + " public String field2222 = \"2222\";\n" + + "\n" + + "\n" + + " protected final String field3 = \"333333333\";\n" + + "}"; + formatSource(source, + "public class Test {\n" + + " String field1 = \"1\";\n" + + "\n" + + " public String field2222 = \"2222\";\n" + + "\n" + + " protected final String field3 = \"333333333\";\n" + + "}" + ); +} +/** + * https://bugs.eclipse.org/479109 - [formatter] Add option to group aligned fields with blank lines + */ +public void testBug479109c() { + this.formatterPrefs.align_type_members_on_columns = true; + this.formatterPrefs.align_fields_grouping_blank_lines = 2; + this.formatterPrefs.number_of_empty_lines_to_preserve = 2; + String source = + "public class Test {\n" + + " String field1 = \"1\"; //\n" + + "\n" + + " public String field2222 = \"2222\"; //\n" + + "\n" + + "\n" + + " protected final String field3 = \"333333333\"; //\n" + + "}"; + formatSource(source, + "public class Test {\n" + + " String field1 = \"1\"; //\n" + + "\n" + + " public String field2222 = \"2222\"; //\n" + + "\n" + + "\n" + + " protected final String field3 = \"333333333\"; //\n" + + "}" + ); +} +/** + * https://bugs.eclipse.org/479109 - [formatter] Add option to group aligned fields with blank lines + */ +public void testBug479109d() { + setFormatLineCommentOnFirstColumn(); + this.formatterPrefs.align_type_members_on_columns = true; + this.formatterPrefs.align_fields_grouping_blank_lines = 2; + String source = + "public class Test {\n" + + " String field1 = \"1\";\n" + + "\n" + + " public String field2222 = \"2222\";\n" + + "\n" + + "// group separator\n" + + "\n" + + " protected final String field3 = \"333333333\";\n" + + "}"; + formatSource(source, + "public class Test {\n" + + " String field1 = \"1\";\n" + + "\n" + + " public String field2222 = \"2222\";\n" + + "\n" + + " // group separator\n" + + "\n" + + " protected final String field3 = \"333333333\";\n" + + "}" + ); +} +/** + * https://bugs.eclipse.org/487375 - [formatter] block comment in front of method signature effects too much indentation + */ +public void testBug486719() { + this.formatterPrefs.page_width = 80; + String source = + "public class Example {\n" + + " int foo(Object a, Object b, Object c) {\n" + + " if (a == b) return 1;if (a == c) return 2; //$IDENTITY-COMPARISON$\n" + + " boolean aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a == b && a == c; //$IDENTITY-COMPARISON$\n" + + " return 3;\n" + + " }\n" + + "}"; + formatSource(source); +} +/** + * https://bugs.eclipse.org/432628 - [formatter] Add option "Insert new line after annotations on enum constants" + */ +public void testBug432628a() { + setComplianceLevel(CompilerOptions.VERSION_1_5); + this.formatterPrefs.insert_new_line_after_annotation_on_enum_constant = false; + String source = + "public enum SomeEnum {\n" + + " @XmlEnumValue(\"val1\") VAL_1(\"val1\"), @XmlEnumValue(\"val2\") VAL_2(\"val2\");\n" + + "}"; + formatSource(source); +} +/** + * https://bugs.eclipse.org/432628 - [formatter] Add option "Insert new line after annotations on enum constants" + */ +public void testBug432628b() { + setComplianceLevel(CompilerOptions.VERSION_1_5); + this.formatterPrefs.insert_new_line_after_annotation_on_enum_constant = true; + String source = + "public enum SomeEnum {\n" + + " @XmlEnumValue(\"val1\")\n" + + " VAL_1(\"val1\"), @XmlEnumValue(\"val2\")\n" + + " VAL_2(\"val2\");\n" + + "}"; + formatSource(source); +} +/** + * https://bugs.eclipse.org/432628 - [formatter] Add option "Insert new line after annotations on enum constants" + */ +public void testBug432628c() { + setComplianceLevel(CompilerOptions.VERSION_1_5); + this.formatterPrefs.insert_new_line_after_annotation_on_enum_constant = true; + this.formatterPrefs.alignment_for_enum_constants = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; + String source = + "public enum SomeEnum {\n" + + " @XmlEnumValue(\"val1\")\n" + + " VAL_1(\"val1\"),\n" + + " @XmlEnumValue(\"val2\")\n" + + " VAL_2(\"val2\");\n" + + "}"; + formatSource(source); +} +/** + * https://bugs.eclipse.org/432628 - [formatter] Add option "Insert new line after annotations on enum constants" + */ +public void testBug432628d() { + setComplianceLevel(CompilerOptions.VERSION_1_5); + this.formatterPrefs.insert_new_line_after_annotation_on_enum_constant = false; + this.formatterPrefs.alignment_for_enum_constants = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; + String source = + "public enum SomeEnum {\n" + + " @XmlEnumValue(\"val1\") VAL_1(\"val1\"),\n" + + " @XmlEnumValue(\"val2\") VAL_2(\"val2\");\n" + + "}"; + formatSource(source); +} +/** + * https://bugs.eclipse.org/118264 - [formatter] Enable wrapping of for loop setup + */ +public void testBug118264a() { + this.formatterPrefs.page_width = 50; + String source = + "class Example {\n" + + " int foo(int argument) {\n" + + " for (int counter = 0; counter < argument; counter++) {\n" + + " doSomething(counter);\n" + + " }\n" + + " }\n" + + "}"; + formatSource(source); +} +/** + * https://bugs.eclipse.org/118264 - [formatter] Enable wrapping of for loop setup + */ +public void testBug118264b() { + this.formatterPrefs.alignment_for_expressions_in_for_loop_header = Alignment.M_COMPACT_SPLIT; + this.formatterPrefs.page_width = 50; + String source = + "class Example {\n" + + " int foo(int argument) {\n" + + " for (int counter = 0; counter < argument; counter++) {\n" + + " doSomething(counter);\n" + + " }\n" + + " }\n" + + "}"; + formatSource(source, + "class Example {\n" + + " int foo(int argument) {\n" + + " for (int counter = 0; counter < argument;\n" + + " counter++) {\n" + + " doSomething(counter);\n" + + " }\n" + + " }\n" + + "}" + ); +} +/** + * https://bugs.eclipse.org/118264 - [formatter] Enable wrapping of for loop setup + */ +public void testBug118264c() { + this.formatterPrefs.alignment_for_expressions_in_for_loop_header = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; + String source = + "class Example {\n" + + " int foo(int argument) {\n" + + " for (int counter = 0; counter < argument; counter++) {\n" + + " doSomething(counter);\n" + + " }\n" + + " }\n" + + "}"; + formatSource(source, + "class Example {\n" + + " int foo(int argument) {\n" + + " for (\n" + + " int counter = 0;\n" + + " counter < argument;\n" + + " counter++) {\n" + + " doSomething(counter);\n" + + " }\n" + + " }\n" + + "}" + ); +} +/** + * https://bugs.eclipse.org/118264 - [formatter] Enable wrapping of for loop setup + */ +public void testBug118264d() { + this.formatterPrefs.alignment_for_expressions_in_for_loop_header = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; + String source = + "class Example {\n" + + " int foo(int argument) {\n" + + " for (int counter = 0; ; ) {\n" + + " doSomething(counter);\n" + + " }\n" + + " }\n" + + "}"; + formatSource(source, + "class Example {\n" + + " int foo(int argument) {\n" + + " for (\n" + + " int counter = 0;;) {\n" + + " doSomething(counter);\n" + + " }\n" + + " }\n" + + "}" + ); +} +/** + * https://bugs.eclipse.org/118264 - [formatter] Enable wrapping of for loop setup + */ +public void testBug118264e() { + this.formatterPrefs.alignment_for_expressions_in_for_loop_header = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; + String source = + "class Example {\n" + + " int foo(int argument) {\n" + + " for (;;argument--, argument--) {\n" + + " doSomething(counter);\n" + + " }\n" + + " }\n" + + "}"; + formatSource(source, + "class Example {\n" + + " int foo(int argument) {\n" + + " for (;;\n" + + " argument--, argument--) {\n" + + " doSomething(counter);\n" + + " }\n" + + " }\n" + + "}" + ); +} +/** + * https://bugs.eclipse.org/118264 - [formatter] Enable wrapping of for loop setup + */ +public void testBug118264f() { + this.formatterPrefs.alignment_for_expressions_in_for_loop_header = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; + String source = + "class Example {\n" + + " int foo(int argument) {\n" + + " for (;;) {\n" + + " doSomething(counter);\n" + + " }\n" + + " }\n" + + "}"; + formatSource(source); +} +/** + * https://bugs.eclipse.org/465910 - [formatter] add a 'wrap before operator' option for conditional expressions + */ +public void testBug465910() { + this.formatterPrefs.alignment_for_conditional_expression = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; + String source = + "class Example {\n" + + " Result foo(boolean argument) {\n" + + " return argument ? doOneThing() : doOtherThing();\n" + + " }\n" + + "}"; + formatSource(source, + "class Example {\n" + + " Result foo(boolean argument) {\n" + + " return argument\n" + + " ? doOneThing()\n" + + " : doOtherThing();\n" + + " }\n" + + "}" + ); + this.formatterPrefs.wrap_before_conditional_operator = false; + formatSource(source, + "class Example {\n" + + " Result foo(boolean argument) {\n" + + " return argument ?\n" + + " doOneThing() :\n" + + " doOtherThing();\n" + + " }\n" + + "}" + ); +} +/** + * https://bugs.eclipse.org/325631 - [formatter] Code formatter Expressions > Assignments lacks "Wrap before operator" option + */ +public void testBug325631() { + this.formatterPrefs.alignment_for_assignment = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; + String source = + "class Example {\n" + + " String value = \"\";\n" + + " void foo(boolean argument) {\n" + + " if (\"test\".equals(value = artument))\n" + + " doSomething();\n" + + " }\n" + + "}"; + formatSource(source, + "class Example {\n" + + " String value =\n" + + " \"\";\n" + + "\n" + + " void foo(boolean argument) {\n" + + " if (\"test\".equals(value =\n" + + " artument))\n" + + " doSomething();\n" + + " }\n" + + "}"); + this.formatterPrefs.wrap_before_assignment_operator = true; + formatSource(source, + "class Example {\n" + + " String value\n" + + " = \"\";\n" + + "\n" + + " void foo(boolean argument) {\n" + + " if (\"test\".equals(value\n" + + " = artument))\n" + + " doSomething();\n" + + " }\n" + + "}" + ); +} +/** + * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions + */ +public void testBug370540a() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out01.java").getSource()); +} +/** + * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions + */ +public void testBug370540b() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.parenthesis_positions_in_method_declaration = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_NOT_EMPTY; + String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out02.java").getSource()); +} +/** + * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions + */ +public void testBug370540c() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.parenthesis_positions_in_method_declaration = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_WRAPPED; + String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out03.java").getSource()); +} +/** + * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions + */ +public void testBug370540d() throws JavaModelException { + this.formatterPrefs.parenthesis_positions_in_method_declaration = DefaultCodeFormatterConstants.SEPARATE_LINES; + setComplianceLevel(CompilerOptions.VERSION_1_8); + String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out04.java").getSource()); +} +/** + * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions + */ +public void testBug370540e() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.parenthesis_positions_in_method_invocation = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_NOT_EMPTY; + String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out05.java").getSource()); +} +/** + * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions + */ +public void testBug370540f() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.parenthesis_positions_in_method_invocation = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_WRAPPED; + this.formatterPrefs.parenthesis_positions_in_enum_constant_declaration = DefaultCodeFormatterConstants.SEPARATE_LINES; + String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out06.java").getSource()); +} +/** + * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions + */ +public void testBug370540g() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.parenthesis_positions_in_enum_constant_declaration = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_NOT_EMPTY; + this.formatterPrefs.parenthesis_positions_in_if_while_statement = DefaultCodeFormatterConstants.SEPARATE_LINES; + String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out07.java").getSource()); +} +/** + * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions + */ +public void testBug370540h() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.parenthesis_positions_in_if_while_statement = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_WRAPPED; + this.formatterPrefs.parenthesis_positions_in_lambda_declaration = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_NOT_EMPTY; + String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out08.java").getSource()); +} +/** + * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions + */ +public void testBug370540i() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.parenthesis_positions_in_if_while_statement = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_WRAPPED; + this.formatterPrefs.parenthesis_positions_in_method_invocation = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_NOT_EMPTY; + String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out09.java").getSource()); +} +/** + * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions + */ +public void testBug370540j() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.parenthesis_positions_in_try_clause = DefaultCodeFormatterConstants.SEPARATE_LINES; + this.formatterPrefs.parenthesis_positions_in_method_declaration = DefaultCodeFormatterConstants.PRESERVE_POSITIONS; + String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out10.java").getSource()); +} +/** + * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions + */ +public void testBug370540k() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.parenthesis_positions_in_catch_clause = DefaultCodeFormatterConstants.SEPARATE_LINES; + this.formatterPrefs.parenthesis_positions_in_if_while_statement = DefaultCodeFormatterConstants.PRESERVE_POSITIONS; + String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out11.java").getSource()); +} +/** + * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions + */ +public void testBug370540l() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.parenthesis_positions_in_for_statement = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_WRAPPED; + this.formatterPrefs.parenthesis_positions_in_annotation = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_NOT_EMPTY; + String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out12.java").getSource()); +} +/** + * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions + */ +public void testBug370540m() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.parenthesis_positions_in_for_statement = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_WRAPPED; + this.formatterPrefs.alignment_for_expressions_in_for_loop_header = Alignment.M_NEXT_PER_LINE_SPLIT + Alignment.M_FORCE; + String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out13.java").getSource()); +} +/** + * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions + */ +public void testBug370540n() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.parenthesis_positions_in_switch_statement = DefaultCodeFormatterConstants.SEPARATE_LINES; + this.formatterPrefs.parenthesis_positions_in_annotation = DefaultCodeFormatterConstants.SEPARATE_LINES; + String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out14.java").getSource()); +} +/** + * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions + */ +public void testBug370540p() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.parenthesis_positions_in_annotation = DefaultCodeFormatterConstants.SEPARATE_LINES; + this.formatterPrefs.parenthesis_positions_in_catch_clause = DefaultCodeFormatterConstants.SEPARATE_LINES; + this.formatterPrefs.parenthesis_positions_in_enum_constant_declaration = DefaultCodeFormatterConstants.SEPARATE_LINES; + this.formatterPrefs.parenthesis_positions_in_for_statement = DefaultCodeFormatterConstants.SEPARATE_LINES; + this.formatterPrefs.parenthesis_positions_in_if_while_statement = DefaultCodeFormatterConstants.SEPARATE_LINES; + this.formatterPrefs.parenthesis_positions_in_lambda_declaration = DefaultCodeFormatterConstants.SEPARATE_LINES; + this.formatterPrefs.parenthesis_positions_in_method_declaration = DefaultCodeFormatterConstants.SEPARATE_LINES; + this.formatterPrefs.parenthesis_positions_in_method_invocation = DefaultCodeFormatterConstants.SEPARATE_LINES; + this.formatterPrefs.parenthesis_positions_in_switch_statement = DefaultCodeFormatterConstants.SEPARATE_LINES; + this.formatterPrefs.parenthesis_positions_in_try_clause = DefaultCodeFormatterConstants.SEPARATE_LINES; + String input = getCompilationUnit("Formatter", "", "test370540", "Example_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test370540", "Example_out15.java").getSource()); +} +/** + * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions + */ +public void testBug370540q() throws JavaModelException { + this.formatterPrefs.parenthesis_positions_in_for_statement = DefaultCodeFormatterConstants.SEPARATE_LINES; + String source = + "public class Test {\n" + + " void foo() {\n" + + " for (\n" + + " String s : Arrays.asList(\"aa\")\n" + + " ) {\n" + + " }\n" + + " }\n" + + "}"; + formatSource(source); +} +/** + * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions + */ +public void testBug370540r() throws JavaModelException { + this.formatterPrefs.parenthesis_positions_in_method_invocation = DefaultCodeFormatterConstants.SEPARATE_LINES; + String source = + "public class Test extends Exception {\n" + + " Test instance = new Test(\n" + + " 1\n" + + " );\n" + + "\n" + + " Test(int a) {\n" + + " this(\n" + + " a, 0\n" + + " );\n" + + " }\n" + + "\n" + + " Test(int a, int b) {\n" + + " super(\n" + + " a + \"=\" + b\n" + + " );\n" + + " }\n" + + "\n" + + " public void printStackTrace() {\n" + + " super.printStackTrace(\n" + + " );\n" + + " }\n" + + "}"; + formatSource(source); +} +/** + * https://bugs.eclipse.org/370540 - [Formatter] New settings for parentheses positions + */ +public void testBug370540s() throws JavaModelException { + this.formatterPrefs.parenthesis_positions_in_method_invocation = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_WRAPPED; + String source = + "public class Test extends Exception {\n" + + " void foo() {\n" + + " new StringBuilder().append(\"aaaaaaaaa\" + \"bbbbbbbbbbbbbbb\" + \"cccccccccccccc\" + \"dddddddddd\")\n" + + " .append(\"aaaaaaa\" + \"bbbbbbbbbbbbb\" + \"cccccccccccccc\" + \"ddddddddd\");\n" + + " }\n" + + "}"; + formatSource(source); +} +/** + * https://bugs.eclipse.org/384959 - [formatter] Add line wrapping options for generics + */ +public void testBug384959a() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + String input = getCompilationUnit("Formatter", "", "test384959", "A_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test384959", "A_out1.java").getSource()); +} +/** + * https://bugs.eclipse.org/384959 - [formatter] Add line wrapping options for generics + */ +public void testBug384959b() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.alignment_for_parameterized_type_references = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; + String input = getCompilationUnit("Formatter", "", "test384959", "A_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test384959", "A_out2.java").getSource()); +} +/** + * https://bugs.eclipse.org/384959 - [formatter] Add line wrapping options for generics + */ +public void testBug384959c() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.alignment_for_type_arguments = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; + String input = getCompilationUnit("Formatter", "", "test384959", "A_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test384959", "A_out3.java").getSource()); +} +/** + * https://bugs.eclipse.org/384959 - [formatter] Add line wrapping options for generics + */ +public void testBug384959d() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.alignment_for_type_parameters = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; + String input = getCompilationUnit("Formatter", "", "test384959", "A_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test384959", "A_out4.java").getSource()); +} +/** + * https://bugs.eclipse.org/384959 - [formatter] Add line wrapping options for generics + */ +public void testBug384959e() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + int policy = Alignment.M_NEXT_SHIFTED_SPLIT + Alignment.M_FORCE; + this.formatterPrefs.alignment_for_parameterized_type_references = policy; + this.formatterPrefs.alignment_for_type_arguments = policy; + this.formatterPrefs.alignment_for_type_parameters = policy; + String input = getCompilationUnit("Formatter", "", "test384959", "A_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test384959", "A_out5.java").getSource()); +} +/** + * https://bugs.eclipse.org/384959 - [formatter] Add line wrapping options for generics + */ +public void testBug384959f() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE; + int policy = Alignment.M_NEXT_PER_LINE_SPLIT + Alignment.M_INDENT_ON_COLUMN + Alignment.M_FORCE; + this.formatterPrefs.alignment_for_parameterized_type_references = policy; + this.formatterPrefs.alignment_for_type_arguments = policy; + this.formatterPrefs.alignment_for_type_parameters = policy; + String input = getCompilationUnit("Formatter", "", "test384959", "A_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test384959", "A_out6.java").getSource()); +} +/** + * https://bugs.eclipse.org/384959 - [formatter] Add line wrapping options for generics + */ +public void testBug384959g() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.alignment_for_type_parameters = Alignment.M_COMPACT_SPLIT; + String source = + "public interface IteratedDescribeLinkList<\n" + + " T extends IteratedDescribeLinkList, E extends IteratedDescribeLink,\n" + + " A extends Iterated, B extends Iterated, C extends IteratedList,\n" + + " D extends IteratedList, F extends MasteredList,\n" + + " G extends MasteredList, H extends Mastered, I extends Mastered, X extends T, Y extends C,\n" + + " Z extends D, J extends F, K extends G> extends ObjectToObjectLinkList {\n" + + "}"; + formatSource(source); +} +/** + * https://bugs.eclipse.org/488642 - [formatter] IOOBE with block comment inside anonymous class + */ +public void testBug488642a() { + this.formatterPrefs.use_tabs_only_for_leading_indentations = true; + String source = + "public class Test {\n" + + " Object o = new Object() {\n" + + " int a = 0;\n" + + " /*\n" + + " * comment\n" + + " */\n" + + " int b = 9; /*\n" + + " * comment\n" + + " */\n" + + " String ssssssss = \"aaaaaaaaaaaaaaaaaaaaaaaa\" //\n" + + " + \"ddddddddddddddddddddddd\" /*\n" + + " * comment\n" + + " */;\n" + + " };\n" + + "}"; + formatSource(source); +} +/** + * https://bugs.eclipse.org/488642 - [formatter] IOOBE with block comment inside anonymous class + */ +public void testBug488642b() { + this.formatterPrefs.use_tabs_only_for_leading_indentations = true; + this.formatterPrefs.align_type_members_on_columns = true; + String source = + "public class Test {\n" + + " Object o = new Object() {\n" + + " int a = 0;\n" + + " /*\n" + + " * comment\n" + + " */\n" + + " int b = 9; /*\n" + + " * comment\n" + + " */\n" + + " String ssssssss = \"aaaaaaaaaaaaaaaaaaaaaaaa\" //\n" + + " + \"ddddddddddddddddddddddd\" /*\n" + + " * comment\n" + + " */;\n" + + " };\n" + + "}"; + formatSource(source); +} +/** + * https://bugs.eclipse.org/493296 - Eclipse formatter hangs when formatting with formatter.join_wrapped_lines=true + */ +public void testBug493296() throws JavaModelException { + setPageWidth80(); + String input = getCompilationUnit("Formatter", "", "test493296", "A_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test493296", "A_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/362260 - [formatter] New feature: count comment width from starting position + */ +public void testBug362260a() throws JavaModelException { + setPageWidth80(); + setFormatLineCommentOnFirstColumn(); + this.formatterPrefs.comment_line_length = 40; + this.formatterPrefs.comment_format_header = true; + this.formatterPrefs.comment_count_line_length_from_starting_position = true; + String input = getCompilationUnit("Formatter", "", "test362260", "A_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test362260", "A_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/362260 - [formatter] New feature: count comment width from starting position + */ +public void testBug362260b() throws JavaModelException { + setPageWidth80(); + this.formatterPrefs.comment_line_length = 40; + this.formatterPrefs.comment_format_header = true; + this.formatterPrefs.comment_count_line_length_from_starting_position = true; + String input = getCompilationUnit("Formatter", "", "test362260", "B_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test362260", "B_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/362260 - [formatter] New feature: count comment width from starting position + */ +public void testBug362260c() throws JavaModelException { + setPageWidth80(); + this.formatterPrefs.comment_line_length = 40; + this.formatterPrefs.comment_format_header = true; + this.formatterPrefs.comment_count_line_length_from_starting_position = true; + this.formatterPrefs.comment_new_lines_at_block_boundaries = false; + String input = getCompilationUnit("Formatter", "", "test362260", "C_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test362260", "C_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/362260 - [formatter] New feature: count comment width from starting position + */ +public void testBug362260d() throws JavaModelException { + setPageWidth80(); + this.formatterPrefs.comment_line_length = 40; + this.formatterPrefs.comment_format_header = true; + this.formatterPrefs.comment_count_line_length_from_starting_position = true; + String input = getCompilationUnit("Formatter", "", "test362260", "D_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test362260", "D_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/362260 - [formatter] New feature: count comment width from starting position + */ +public void testBug362260e() throws JavaModelException { + setPageWidth80(); + this.formatterPrefs.comment_line_length = 40; + this.formatterPrefs.comment_format_header = true; + this.formatterPrefs.comment_count_line_length_from_starting_position = true; + this.formatterPrefs.comment_new_lines_at_javadoc_boundaries = false; + String input = getCompilationUnit("Formatter", "", "test362260", "E_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test362260", "E_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/362260 - [formatter] New feature: count comment width from starting position + */ +public void testBug362260f() throws JavaModelException { + setPageWidth80(); + this.formatterPrefs.comment_line_length = 40; + this.formatterPrefs.comment_count_line_length_from_starting_position = true; + this.formatterPrefs.comment_preserve_white_space_between_code_and_line_comments = true; + String input = getCompilationUnit("Formatter", "", "test362260", "F_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test362260", "F_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/362260 - [formatter] New feature: count comment width from starting position + */ +public void testBug362260g() throws JavaModelException { + setPageWidth80(); + this.formatterPrefs.comment_line_length = 40; + this.formatterPrefs.comment_format_header = true; + this.formatterPrefs.comment_count_line_length_from_starting_position = true; + String input = getCompilationUnit("Formatter", "", "test362260", "G_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test362260", "G_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/506430 - [1.9] Formatter support for module-info.java + */ +public void testBug506430a() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_9); + setPageWidth80(); + String input = getCompilationUnit("Formatter", "", "test506430", "A_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test506430", "A_out.java") .getSource(), + CodeFormatter.K_MODULE_INFO | CodeFormatter.F_INCLUDE_COMMENTS); +} +/** + * https://bugs.eclipse.org/506430 - [1.9] Formatter support for module-info.java + */ +public void testBug506430b() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_9); + setPageWidth80(); + this.formatterPrefs.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE; + this.formatterPrefs.blank_lines_before_new_chunk = 2; + this.formatterPrefs.blank_lines_before_first_class_body_declaration = 3; + this.formatterPrefs.blank_lines_before_field = 1; + this.formatterPrefs.indent_body_declarations_compare_to_type_header = false; + this.formatterPrefs.insert_space_before_comma_in_multiple_field_declarations = true; + this.formatterPrefs.alignment_for_module_statements = Alignment.M_NEXT_PER_LINE_SPLIT; + this.formatterPrefs.insert_new_line_at_end_of_file_if_missing = true; + String input = getCompilationUnit("Formatter", "", "test506430", "B_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test506430", "B_out.java") .getSource(), + CodeFormatter.K_MODULE_INFO | CodeFormatter.F_INCLUDE_COMMENTS); +} +/** + * https://bugs.eclipse.org/506430 - [1.9] Formatter support for module-info.java + */ +public void testBug506430c() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_9); + setPageWidth80(); + String input = getCompilationUnit("Formatter", "", "test506430", "A_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test506430", "A_out.java") .getSource(), + CodeFormatter.K_UNKNOWN | CodeFormatter.F_INCLUDE_COMMENTS); +} + +/** + * https://bugs.eclipse.org/518235 - [1.8][formatter] Receiver parameter breaks whitespace rule + */ +public void testBug518235() throws JavaModelException { + String source = + "public class Base {\n" + + " class Base2 {\n" + + " Base2(Base Base.this) {\n" + + " }\n" + + " }\n" + + "\n" + + " T foo(@Deprecated Base this, final Base bar1, final Base bar2) {\n" + + " }\n" + + "}"; + formatSource(source); +} + +/** + * https://bugs.eclipse.org/128653 - [formatter] Improve tag description indentation in javadoc + */ +public void testBug128653a() throws JavaModelException { + this.formatterPrefs.comment_indent_root_tags = false; + this.formatterPrefs.comment_align_tags_names_descriptions = false; + this.formatterPrefs.comment_align_tags_descriptions_grouped = false; + this.formatterPrefs.comment_indent_parameter_description = false; + this.formatterPrefs.comment_insert_new_line_for_parameter = false; + String input = getCompilationUnit("Formatter", "", "test128653", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test128653", "A_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/128653 - [formatter] Improve tag description indentation in javadoc + */ +public void testBug128653b() throws JavaModelException { + this.formatterPrefs.comment_indent_root_tags = true; + this.formatterPrefs.comment_align_tags_names_descriptions = false; + this.formatterPrefs.comment_align_tags_descriptions_grouped = false; + this.formatterPrefs.comment_indent_parameter_description = false; + this.formatterPrefs.comment_insert_new_line_for_parameter = false; + String input = getCompilationUnit("Formatter", "", "test128653", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test128653", "B_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/128653 - [formatter] Improve tag description indentation in javadoc + */ +public void testBug128653c() throws JavaModelException { + this.formatterPrefs.comment_indent_root_tags = false; + this.formatterPrefs.comment_align_tags_names_descriptions = true; + this.formatterPrefs.comment_align_tags_descriptions_grouped = false; + this.formatterPrefs.comment_indent_parameter_description = false; + this.formatterPrefs.comment_insert_new_line_for_parameter = false; + String input = getCompilationUnit("Formatter", "", "test128653", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test128653", "C_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/128653 - [formatter] Improve tag description indentation in javadoc + */ +public void testBug128653d() throws JavaModelException { + this.formatterPrefs.comment_indent_root_tags = false; + this.formatterPrefs.comment_align_tags_names_descriptions = false; + this.formatterPrefs.comment_align_tags_descriptions_grouped = true; + this.formatterPrefs.comment_indent_parameter_description = false; + this.formatterPrefs.comment_insert_new_line_for_parameter = false; + String input = getCompilationUnit("Formatter", "", "test128653", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test128653", "D_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/128653 - [formatter] Improve tag description indentation in javadoc + */ +public void testBug128653e() throws JavaModelException { + this.formatterPrefs.comment_indent_root_tags = false; + this.formatterPrefs.comment_align_tags_names_descriptions = true; + this.formatterPrefs.comment_align_tags_descriptions_grouped = false; + this.formatterPrefs.comment_indent_parameter_description = true; + this.formatterPrefs.comment_insert_new_line_for_parameter = false; + String input = getCompilationUnit("Formatter", "", "test128653", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test128653", "E_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/128653 - [formatter] Improve tag description indentation in javadoc + */ +public void testBug128653f() throws JavaModelException { + this.formatterPrefs.comment_indent_root_tags = false; + this.formatterPrefs.comment_align_tags_names_descriptions = true; + this.formatterPrefs.comment_align_tags_descriptions_grouped = false; + this.formatterPrefs.comment_indent_parameter_description = false; + this.formatterPrefs.comment_insert_new_line_for_parameter = true; + String input = getCompilationUnit("Formatter", "", "test128653", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test128653", "F_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/128653 - [formatter] Improve tag description indentation in javadoc + */ +public void testBug128653g() throws JavaModelException { + this.formatterPrefs.comment_indent_root_tags = false; + this.formatterPrefs.comment_align_tags_names_descriptions = false; + this.formatterPrefs.comment_align_tags_descriptions_grouped = true; + this.formatterPrefs.comment_indent_parameter_description = true; + this.formatterPrefs.comment_insert_new_line_for_parameter = true; + String input = getCompilationUnit("Formatter", "", "test128653", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test128653", "G_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/128653 - [formatter] Improve tag description indentation in javadoc + */ +public void testBug128653h() throws JavaModelException { + this.formatterPrefs.comment_indent_root_tags = false; + this.formatterPrefs.comment_align_tags_names_descriptions = false; + this.formatterPrefs.comment_align_tags_descriptions_grouped = false; + this.formatterPrefs.comment_indent_parameter_description = true; + this.formatterPrefs.comment_insert_new_line_for_parameter = true; + String input = getCompilationUnit("Formatter", "", "test128653", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test128653", "H_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/128653 - [formatter] Improve tag description indentation in javadoc + */ +public void testBug128653i() throws JavaModelException { + this.formatterPrefs.comment_indent_root_tags = true; + this.formatterPrefs.comment_align_tags_names_descriptions = false; + this.formatterPrefs.comment_align_tags_descriptions_grouped = false; + this.formatterPrefs.comment_indent_parameter_description = true; + this.formatterPrefs.comment_insert_new_line_for_parameter = false; + String input = getCompilationUnit("Formatter", "", "test128653", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test128653", "I_out.java").getSource()); +} + +/** + * https://bugs.eclipse.org/104910 - [formatter] add "keep simple for/while on one line" option + */ +public void testBug104910a() throws JavaModelException { + this.formatterPrefs.keep_simple_for_body_on_same_line = true; + String input = getCompilationUnit("Formatter", "", "test104910", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test104910", "A_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/104910 - [formatter] add "keep simple for/while on one line" option + */ +public void testBug104910b() throws JavaModelException { + this.formatterPrefs.keep_simple_while_body_on_same_line = true; + String input = getCompilationUnit("Formatter", "", "test104910", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test104910", "B_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/104910 - [formatter] add "keep simple for/while on one line" option + */ +public void testBug104910c() throws JavaModelException { + this.formatterPrefs.keep_simple_do_while_body_on_same_line = true; + String input = getCompilationUnit("Formatter", "", "test104910", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test104910", "C_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/104910 - [formatter] add "keep simple for/while on one line" option + */ +public void testBug104910d() throws JavaModelException { + this.formatterPrefs.keep_simple_for_body_on_same_line = true; + this.formatterPrefs.keep_simple_while_body_on_same_line = true; + this.formatterPrefs.keep_simple_do_while_body_on_same_line = true; + this.formatterPrefs.keep_simple_if_on_one_line = true; + this.formatterPrefs.alignment_for_compact_if = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; + this.formatterPrefs.alignment_for_compact_loop = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; + this.formatterPrefs.use_tabs_only_for_leading_indentations = true; + String input = getCompilationUnit("Formatter", "", "test104910", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test104910", "D_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/104910 - [formatter] add "keep simple for/while on one line" option + */ +public void testBug104910e() throws JavaModelException { + this.formatterPrefs.keep_simple_for_body_on_same_line = true; + this.formatterPrefs.keep_simple_while_body_on_same_line = true; + this.formatterPrefs.keep_simple_do_while_body_on_same_line = true; + this.formatterPrefs.keep_simple_if_on_one_line = true; + this.formatterPrefs.use_tabs_only_for_leading_indentations = true; + this.formatterPrefs.page_width = 55; + String input = getCompilationUnit("Formatter", "", "test104910", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test104910", "E_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/104910 - [formatter] add "keep simple for/while on one line" option + */ +public void testBug104910f() throws JavaModelException { + this.formatterPrefs.keep_simple_for_body_on_same_line = true; + this.formatterPrefs.keep_simple_while_body_on_same_line = true; + this.formatterPrefs.keep_simple_do_while_body_on_same_line = true; + this.formatterPrefs.keep_simple_if_on_one_line = true; + this.formatterPrefs.alignment_for_compact_if = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; + this.formatterPrefs.alignment_for_compact_loop = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; + this.formatterPrefs.use_tabs_only_for_leading_indentations = true; + String input = getCompilationUnit("Formatter", "", "test104910", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test104910", "F_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/104910 - [formatter] add "keep simple for/while on one line" option + */ +public void testBug104910g() throws JavaModelException { + this.formatterPrefs.keep_simple_for_body_on_same_line = true; + this.formatterPrefs.keep_simple_while_body_on_same_line = true; + this.formatterPrefs.keep_simple_do_while_body_on_same_line = true; + this.formatterPrefs.keep_simple_if_on_one_line = true; + this.formatterPrefs.alignment_for_compact_if = Alignment.M_NO_ALIGNMENT; + this.formatterPrefs.page_width = 40; + String input = getCompilationUnit("Formatter", "", "test104910", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test104910", "G_out.java").getSource()); +} + +/** + * https://bugs.eclipse.org/530756 - [formatter] Align fields in columns: add option to use spaces + */ +public void testBug530756a() throws JavaModelException { + this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.TAB; + this.formatterPrefs.align_type_members_on_columns = true; + String input = getCompilationUnit("Formatter", "", "test530756", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test530756", "A_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/530756 - [formatter] Align fields in columns: add option to use spaces + */ +public void testBug530756b() throws JavaModelException { + this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.TAB; + this.formatterPrefs.align_type_members_on_columns = true; + this.formatterPrefs.align_with_spaces = true; + String input = getCompilationUnit("Formatter", "", "test530756", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test530756", "B_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/530756 - [formatter] Align fields in columns: add option to use spaces + */ +public void testBug530756c() throws JavaModelException { + this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.MIXED; + this.formatterPrefs.indentation_size = 6; + this.formatterPrefs.align_type_members_on_columns = true; + this.formatterPrefs.align_with_spaces = true; + String input = getCompilationUnit("Formatter", "", "test530756", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test530756", "C_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/530756 - [formatter] Align fields in columns: add option to use spaces + */ +public void testBug530756d() throws JavaModelException { + this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE; + this.formatterPrefs.align_type_members_on_columns = true; + this.formatterPrefs.align_with_spaces = true; + String input = getCompilationUnit("Formatter", "", "test530756", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test530756", "D_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/530756 - [formatter] Align fields in columns: add option to use spaces + */ +public void testBug530756e() throws JavaModelException { + this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE; + this.formatterPrefs.align_type_members_on_columns = true; + this.formatterPrefs.align_with_spaces = false; + String input = getCompilationUnit("Formatter", "", "test530756", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test530756", "E_out.java").getSource()); +} + +/** + * https://bugs.eclipse.org/131292 - [format] align assignments in columns + */ +public void testBug131292a() throws JavaModelException { + this.formatterPrefs.align_type_members_on_columns = true; + String input = getCompilationUnit("Formatter", "", "test131292", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test131292", "A_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/131292 - [format] align assignments in columns + */ +public void testBug131292b() throws JavaModelException { + this.formatterPrefs.align_variable_declarations_on_columns = true; + String input = getCompilationUnit("Formatter", "", "test131292", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test131292", "B_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/131292 - [format] align assignments in columns + */ +public void testBug131292c() throws JavaModelException { + this.formatterPrefs.align_assignment_statements_on_columns = true; + String input = getCompilationUnit("Formatter", "", "test131292", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test131292", "C_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/131292 - [format] align assignments in columns + */ +public void testBug131292d() throws JavaModelException { + this.formatterPrefs.align_type_members_on_columns = true; + this.formatterPrefs.align_variable_declarations_on_columns = true; + this.formatterPrefs.align_assignment_statements_on_columns = true; + this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE; + String input = getCompilationUnit("Formatter", "", "test131292", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test131292", "D_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/131292 - [format] align assignments in columns + */ +public void testBug131292e() throws JavaModelException { + this.formatterPrefs.align_type_members_on_columns = true; + this.formatterPrefs.align_variable_declarations_on_columns = true; + this.formatterPrefs.align_assignment_statements_on_columns = true; + this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.MIXED; + this.formatterPrefs.align_fields_grouping_blank_lines = 1; + String input = getCompilationUnit("Formatter", "", "test131292", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test131292", "E_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/131292 - [format] align assignments in columns + */ +public void testBug131292f() throws JavaModelException { + this.formatterPrefs.align_type_members_on_columns = true; + this.formatterPrefs.align_variable_declarations_on_columns = true; + this.formatterPrefs.align_assignment_statements_on_columns = true; + this.formatterPrefs.align_with_spaces = true; + this.formatterPrefs.align_fields_grouping_blank_lines = 2; + String input = getCompilationUnit("Formatter", "", "test131292", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test131292", "F_out.java").getSource()); +} + +/** + * https://bugs.eclipse.org/205973 - [formatter] Allow to keep simple methods on one line (for exemple simple getter or setter) + */ +public void testBug205973a() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.keep_annotation_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + this.formatterPrefs.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + this.formatterPrefs.keep_if_then_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + this.formatterPrefs.keep_lambda_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + this.formatterPrefs.keep_loop_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + this.formatterPrefs.keep_code_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_enum_constant_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_enum_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_simple_getter_setter_on_one_line = false; + this.formatterPrefs.keep_guardian_clause_on_one_line = false; + String input = getCompilationUnit("Formatter", "", "test205973", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test205973", "A_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/205973 - [formatter] Allow to keep simple methods on one line (for exemple simple getter or setter) + */ +public void testBug205973b() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.keep_annotation_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_if_then_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_lambda_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM; + this.formatterPrefs.keep_loop_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM; + this.formatterPrefs.keep_code_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_enum_constant_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + this.formatterPrefs.keep_enum_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + this.formatterPrefs.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_simple_getter_setter_on_one_line = true; + this.formatterPrefs.keep_guardian_clause_on_one_line = false; + String input = getCompilationUnit("Formatter", "", "test205973", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test205973", "B_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/205973 - [formatter] Allow to keep simple methods on one line (for exemple simple getter or setter) + */ +public void testBug205973c() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.keep_annotation_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM; + this.formatterPrefs.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM; + this.formatterPrefs.keep_if_then_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_lambda_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_loop_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_code_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + this.formatterPrefs.keep_enum_constant_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_enum_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM; + this.formatterPrefs.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + this.formatterPrefs.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + this.formatterPrefs.keep_simple_getter_setter_on_one_line = false; + this.formatterPrefs.keep_guardian_clause_on_one_line = true; + String input = getCompilationUnit("Formatter", "", "test205973", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test205973", "C_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/205973 - [formatter] Allow to keep simple methods on one line (for exemple simple getter or setter) + */ +public void testBug205973d() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.keep_annotation_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + this.formatterPrefs.keep_if_then_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_lambda_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM; + this.formatterPrefs.keep_loop_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_code_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + this.formatterPrefs.keep_enum_constant_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM; + this.formatterPrefs.keep_enum_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM; + this.formatterPrefs.keep_simple_getter_setter_on_one_line = false; + this.formatterPrefs.keep_guardian_clause_on_one_line = false; + String input = getCompilationUnit("Formatter", "", "test205973", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test205973", "D_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/205973 - [formatter] Allow to keep simple methods on one line (for exemple simple getter or setter) + */ +public void testBug205973e() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.keep_annotation_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + this.formatterPrefs.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_if_then_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + this.formatterPrefs.keep_lambda_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_loop_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + this.formatterPrefs.keep_code_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_enum_constant_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + this.formatterPrefs.keep_enum_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + this.formatterPrefs.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_simple_getter_setter_on_one_line = true; + this.formatterPrefs.keep_guardian_clause_on_one_line = true; + String input = getCompilationUnit("Formatter", "", "test205973", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test205973", "E_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/205973 - [formatter] Allow to keep simple methods on one line (for exemple simple getter or setter) + */ +public void testBug205973f() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.keep_annotation_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + this.formatterPrefs.keep_if_then_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + this.formatterPrefs.keep_lambda_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_loop_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM; + this.formatterPrefs.keep_code_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_enum_constant_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + this.formatterPrefs.keep_enum_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + this.formatterPrefs.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + this.formatterPrefs.keep_simple_getter_setter_on_one_line = false; + this.formatterPrefs.keep_guardian_clause_on_one_line = false; + String input = getCompilationUnit("Formatter", "", "test205973", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test205973", "F_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/205973 - [formatter] Allow to keep simple methods on one line (for exemple simple getter or setter) + */ +public void testBug205973g() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.keep_annotation_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + this.formatterPrefs.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_if_then_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM; + this.formatterPrefs.keep_lambda_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + this.formatterPrefs.keep_loop_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_code_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + this.formatterPrefs.keep_enum_constant_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_enum_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM; + this.formatterPrefs.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + this.formatterPrefs.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_simple_getter_setter_on_one_line = false; + this.formatterPrefs.keep_guardian_clause_on_one_line = false; + String input = getCompilationUnit("Formatter", "", "test205973", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test205973", "G_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/205973 - [formatter] Allow to keep simple methods on one line (for exemple simple getter or setter) + */ +public void testBug205973h() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.keep_annotation_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_PRESERVE; + this.formatterPrefs.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_PRESERVE; + this.formatterPrefs.keep_if_then_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_PRESERVE; + this.formatterPrefs.keep_lambda_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_PRESERVE; + this.formatterPrefs.keep_loop_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_PRESERVE; + this.formatterPrefs.keep_code_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_NEVER; + this.formatterPrefs.keep_enum_constant_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_PRESERVE; + this.formatterPrefs.keep_enum_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_PRESERVE; + this.formatterPrefs.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_PRESERVE; + this.formatterPrefs.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_PRESERVE; + this.formatterPrefs.keep_simple_getter_setter_on_one_line = false; + this.formatterPrefs.keep_guardian_clause_on_one_line = false; + this.formatterPrefs.align_type_members_on_columns = true; + this.formatterPrefs.align_variable_declarations_on_columns = true; + this.formatterPrefs.align_assignment_statements_on_columns = true; + String input = getCompilationUnit("Formatter", "", "test205973", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test205973", "H_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/205973 - [formatter] Allow to keep simple methods on one line (for exemple simple getter or setter) + */ +public void testBug205973i() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.page_width = 50; + this.formatterPrefs.use_tabs_only_for_leading_indentations = true; + this.formatterPrefs.keep_annotation_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + this.formatterPrefs.keep_anonymous_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + this.formatterPrefs.keep_if_then_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + this.formatterPrefs.keep_lambda_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + this.formatterPrefs.keep_loop_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + this.formatterPrefs.keep_code_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY; + this.formatterPrefs.keep_enum_constant_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + this.formatterPrefs.keep_enum_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + this.formatterPrefs.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + this.formatterPrefs.keep_type_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + this.formatterPrefs.keep_simple_getter_setter_on_one_line = false; + this.formatterPrefs.keep_guardian_clause_on_one_line = false; + String input = getCompilationUnit("Formatter", "", "test205973", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test205973", "I_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/205973 - [formatter] Allow to keep simple methods on one line (for exemple simple getter or setter) + */ +public void testBug205973j() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.keep_method_body_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + String input = getCompilationUnit("Formatter", "", "test205973", "J_in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test205973", "J_out.java").getSource()); +} + +/** + * https://bugs.eclipse.org/541133 - [formatter] javadoc: no indent of @return description + */ +public void testBug541133a() { + this.formatterPrefs.comment_align_tags_descriptions_grouped = false; + this.formatterPrefs.comment_indent_parameter_description = false; + this.formatterPrefs.comment_indent_tag_description = true; + String source = + "class C {\n" + + " /**\n" + + " * @param bar param description should NOT get additional indentation when it's wrapped\n" + + " * @return return description should get additional indentation when it's wrapped\n" + + " */\n" + + " String foo(String bar) {\n" + + " }\n" + + "}"; + formatSource(source, + "class C {\n" + + " /**\n" + + " * @param bar param description should NOT get additional indentation when it's\n" + + " * wrapped\n" + + " * @return return description should get additional indentation when it's\n" + + " * wrapped\n" + + " */\n" + + " String foo(String bar) {\n" + + " }\n" + + "}"); +} +/** + * https://bugs.eclipse.org/541133 - [formatter] javadoc: no indent of @return description + */ +public void testBug541133b() { + this.formatterPrefs.comment_indent_root_tags = true; + this.formatterPrefs.comment_indent_parameter_description = false; + this.formatterPrefs.comment_indent_tag_description = true; + String source = + "class C {\n" + + " /**\n" + + " * @deprecated Do not use this class, it's only to test formatting on. One two three four five six seven eight nine ten\n" + + " */\n" + + " void foo() {\n" + + " }\n" + + "}"; + formatSource(source, + "class C {\n" + + " /**\n" + + " * @deprecated Do not use this class, it's only to test formatting on. One two\n" + + " * three four five six seven eight nine ten\n" + + " */\n" + + " void foo() {\n" + + " }\n" + + "}"); +} +/** + * https://bugs.eclipse.org/541133 - [formatter] javadoc: no indent of @return description + */ +public void testBug541133c() { + this.formatterPrefs.comment_indent_tag_description = true; + String source = + "/**\n" + + " * Mensagens SMTP tem o seguinte formato:\n" + + " * \n" + + " *
\n" +
+		" * resposta de uma linha só:\n" +
+		" * 
\n" + + " * \n" + + " * {@link java.lang.String
a simple string}.\n" + + " * \n" + + " * @deprecated Mensagens SMTP tem o seguinte formato:\n" + + " * \n" + + " *
\n" +
+		" *                 resposta de uma linha só:\n" +
+		" *                 
\n" + + " */"; + formatSource(source); +} +/** + * https://bugs.eclipse.org/541133 - [formatter] javadoc: no indent of @return description + */ +public void testBug541133d() { + String source = + "/**\n" + + " * @return something
\n" +
+		" * class Runnable {\n" +
+		" * 	// Hello really bad Ganymede formatter !!!\n" +
+		" * 	// Shit happens when somebody tries to change a running system\n" +
+		" * }
something\n" + + " */"; + formatSource(source, + "/**\n" + + " * @return something\n" + + " * \n" + + " *
\n" +
+		" *         class Runnable {\n" +
+		" *         	// Hello really bad Ganymede formatter !!!\n" +
+		" *         	// Shit happens when somebody tries to change a running system\n" +
+		" *         }\n" +
+		" *         
\n" + + " * \n" + + " * something\n" + + " */"); +} + +/** + * https://bugs.eclipse.org/543079 - [formatter] wrapping binary expressions: separate options for operator types + */ +public void testBug543079a() throws JavaModelException { + this.formatterPrefs.page_width = 80; + this.formatterPrefs.alignment_for_multiplicative_operator = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; + this.formatterPrefs.wrap_before_multiplicative_operator = false; + String input = getCompilationUnit("Formatter", "", "test543079", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test543079", "A_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/543079 - [formatter] wrapping binary expressions: separate options for operator types + */ +public void testBug543079b() throws JavaModelException { + this.formatterPrefs.page_width = 80; + this.formatterPrefs.alignment_for_additive_operator = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; + this.formatterPrefs.wrap_before_additive_operator = false; + String input = getCompilationUnit("Formatter", "", "test543079", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test543079", "B_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/543079 - [formatter] wrapping binary expressions: separate options for operator types + */ +public void testBug543079c() throws JavaModelException { + this.formatterPrefs.page_width = 80; + this.formatterPrefs.alignment_for_string_concatenation = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; + this.formatterPrefs.wrap_before_string_concatenation = false; + String input = getCompilationUnit("Formatter", "", "test543079", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test543079", "C_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/543079 - [formatter] wrapping binary expressions: separate options for operator types + */ +public void testBug543079d() throws JavaModelException { + this.formatterPrefs.page_width = 80; + this.formatterPrefs.alignment_for_shift_operator = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; + this.formatterPrefs.wrap_before_shift_operator = false; + String input = getCompilationUnit("Formatter", "", "test543079", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test543079", "D_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/543079 - [formatter] wrapping binary expressions: separate options for operator types + */ +public void testBug543079e() throws JavaModelException { + this.formatterPrefs.page_width = 80; + this.formatterPrefs.alignment_for_relational_operator = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; + this.formatterPrefs.wrap_before_relational_operator = false; + String input = getCompilationUnit("Formatter", "", "test543079", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test543079", "E_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/543079 - [formatter] wrapping binary expressions: separate options for operator types + */ +public void testBug543079f() throws JavaModelException { + this.formatterPrefs.page_width = 80; + this.formatterPrefs.alignment_for_bitwise_operator = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; + this.formatterPrefs.wrap_before_bitwise_operator = false; + String input = getCompilationUnit("Formatter", "", "test543079", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test543079", "F_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/543079 - [formatter] wrapping binary expressions: separate options for operator types + */ +public void testBug543079g() throws JavaModelException { + this.formatterPrefs.page_width = 80; + this.formatterPrefs.alignment_for_logical_operator = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; + this.formatterPrefs.wrap_before_logical_operator = false; + String input = getCompilationUnit("Formatter", "", "test543079", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test543079", "G_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/159565 - [formatter] Separate white space preferences for separate operators + */ +public void testBug159565a() throws JavaModelException { + this.formatterPrefs.insert_space_before_multiplicative_operator = false; + this.formatterPrefs.insert_space_before_bitwise_operator = false; + String input = getCompilationUnit("Formatter", "", "test159565", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test159565", "A_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/159565 - [formatter] Separate white space preferences for separate operators + */ +public void testBug159565b() throws JavaModelException { + this.formatterPrefs.insert_space_after_multiplicative_operator = false; + this.formatterPrefs.insert_space_after_additive_operator = false; + String input = getCompilationUnit("Formatter", "", "test159565", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test159565", "B_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/159565 - [formatter] Separate white space preferences for separate operators + */ +public void testBug159565c() throws JavaModelException { + this.formatterPrefs.insert_space_before_additive_operator = false; + this.formatterPrefs.insert_space_before_logical_operator = false; + String input = getCompilationUnit("Formatter", "", "test159565", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test159565", "C_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/159565 - [formatter] Separate white space preferences for separate operators + */ +public void testBug159565d() throws JavaModelException { + this.formatterPrefs.insert_space_before_string_concatenation = false; + this.formatterPrefs.insert_space_after_bitwise_operator = false; + String input = getCompilationUnit("Formatter", "", "test159565", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test159565", "D_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/159565 - [formatter] Separate white space preferences for separate operators + */ +public void testBug159565e() throws JavaModelException { + this.formatterPrefs.insert_space_after_string_concatenation = false; + this.formatterPrefs.insert_space_before_shift_operator = false; + String input = getCompilationUnit("Formatter", "", "test159565", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test159565", "E_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/159565 - [formatter] Separate white space preferences for separate operators + */ +public void testBug159565f() throws JavaModelException { + this.formatterPrefs.insert_space_after_shift_operator = false; + this.formatterPrefs.insert_space_after_relational_operator = false; + String input = getCompilationUnit("Formatter", "", "test159565", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test159565", "F_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/159565 - [formatter] Separate white space preferences for separate operators + */ +public void testBug159565g() throws JavaModelException { + this.formatterPrefs.insert_space_before_relational_operator = false; + this.formatterPrefs.insert_space_after_logical_operator = false; + String input = getCompilationUnit("Formatter", "", "test159565", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test159565", "G_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/541011 - [formatter] Option to wrap chained conditionals as one group + */ +public void testBug541011a() throws JavaModelException { + this.formatterPrefs.page_width = 80; + String input = getCompilationUnit("Formatter", "", "test541011", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test541011", "A_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/541011 - [formatter] Option to wrap chained conditionals as one group + */ +public void testBug541011b() throws JavaModelException { + this.formatterPrefs.page_width = 80; + this.formatterPrefs.alignment_for_conditional_expression_chain = Alignment.M_COMPACT_SPLIT; + String input = getCompilationUnit("Formatter", "", "test541011", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test541011", "B_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/541011 - [formatter] Option to wrap chained conditionals as one group + */ +public void testBug541011c() throws JavaModelException { + this.formatterPrefs.page_width = 80; + this.formatterPrefs.alignment_for_conditional_expression_chain = Alignment.M_ONE_PER_LINE_SPLIT; + String input = getCompilationUnit("Formatter", "", "test541011", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test541011", "C_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/541011 - [formatter] Option to wrap chained conditionals as one group + */ +public void testBug541011d() throws JavaModelException { + this.formatterPrefs.page_width = 80; + this.formatterPrefs.alignment_for_conditional_expression_chain = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; + String input = getCompilationUnit("Formatter", "", "test541011", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test541011", "D_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/541011 - [formatter] Option to wrap chained conditionals as one group + */ +public void testBug541011e() throws JavaModelException { + this.formatterPrefs.page_width = 80; + this.formatterPrefs.alignment_for_conditional_expression_chain = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; + this.formatterPrefs.alignment_for_conditional_expression = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; + String input = getCompilationUnit("Formatter", "", "test541011", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test541011", "E_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/541011 - [formatter] Option to wrap chained conditionals as one group + */ +public void testBug541011f() throws JavaModelException { + this.formatterPrefs.page_width = 80; + this.formatterPrefs.alignment_for_conditional_expression_chain = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; + this.formatterPrefs.alignment_for_conditional_expression = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; + String input = getCompilationUnit("Formatter", "", "test541011", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test541011", "F_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/541011 - [formatter] Option to wrap chained conditionals as one group + */ +public void testBug541011g() throws JavaModelException { + this.formatterPrefs.page_width = 80; + this.formatterPrefs.alignment_for_conditional_expression = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE + Alignment.M_INDENT_ON_COLUMN; + String input = getCompilationUnit("Formatter", "", "test541011", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test541011", "G_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/543818 - [12] Formatter Support for Switch Expressions + */ +public void testBug543818a() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_14); + this.formatterPrefs.insert_space_before_comma_in_switch_case_expressions = true; + this.formatterPrefs.insert_space_before_colon_in_case = true; + this.formatterPrefs.indent_switchstatements_compare_to_switch = true; + String input = getCompilationUnit("Formatter", "", "test543818", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test543818", "A_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/543818 - [12] Formatter Support for Switch Expressions + */ +public void testBug543818b() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_14); + this.formatterPrefs.insert_space_after_comma_in_switch_case_expressions = false; + this.formatterPrefs.insert_space_before_closing_paren_in_switch = true; + this.formatterPrefs.indent_switchstatements_compare_to_cases = false; + String input = getCompilationUnit("Formatter", "", "test543818", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test543818", "B_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/543818 - [12] Formatter Support for Switch Expressions + */ +public void testBug543818c() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_14); + this.formatterPrefs.insert_space_before_arrow_in_switch_case = false; + this.formatterPrefs.insert_space_before_opening_paren_in_switch = false; + this.formatterPrefs.indent_breaks_compare_to_cases = false; + String input = getCompilationUnit("Formatter", "", "test543818", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test543818", "C_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/543818 - [12] Formatter Support for Switch Expressions + */ +public void testBug543818d() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_14); + this.formatterPrefs.insert_space_after_arrow_in_switch_case = false; + this.formatterPrefs.insert_space_after_opening_paren_in_switch = true; + this.formatterPrefs.insert_space_before_opening_brace_in_block = false; + this.formatterPrefs.brace_position_for_switch = DefaultCodeFormatterConstants.NEXT_LINE; + String input = getCompilationUnit("Formatter", "", "test543818", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test543818", "D_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/543818 - [12] Formatter Support for Switch Expressions + */ +public void testBug543818e() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_14); + this.formatterPrefs.insert_space_before_arrow_in_switch_default = false; + this.formatterPrefs.insert_space_before_colon_in_default = true; + this.formatterPrefs.parenthesis_positions_in_switch_statement = DefaultCodeFormatterConstants.SEPARATE_LINES; + String input = getCompilationUnit("Formatter", "", "test543818", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test543818", "E_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/543818 - [12] Formatter Support for Switch Expressions + */ +public void testBug543818f() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_14); + this.formatterPrefs.insert_space_after_arrow_in_switch_default = false; + this.formatterPrefs.insert_space_before_opening_brace_in_switch = false; + this.formatterPrefs.insert_space_before_opening_brace_in_block = false; + String input = getCompilationUnit("Formatter", "", "test543818", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test543818", "F_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/543818 - [12] Formatter Support for Switch Expressions + */ +public void testBug543818g() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_14); + String input = getCompilationUnit("Formatter", "", "test543818", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test543818", "G_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/549249 - [formatter] Extend Blank Lines settings to remove excess lines + */ +public void testBug549249a() throws JavaModelException { + this.formatterPrefs.number_of_empty_lines_to_preserve = 4; + this.formatterPrefs.blank_lines_after_imports = ~2; + String input = getCompilationUnit("Formatter", "", "test549249", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test549249", "A_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/549249 - [formatter] Extend Blank Lines settings to remove excess lines + */ +public void testBug549249b() throws JavaModelException { + this.formatterPrefs.number_of_empty_lines_to_preserve = 4; + this.formatterPrefs.blank_lines_after_package = ~1; + String input = getCompilationUnit("Formatter", "", "test549249", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test549249", "B_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/549249 - [formatter] Extend Blank Lines settings to remove excess lines + */ +public void testBug549249c() throws JavaModelException { + this.formatterPrefs.number_of_empty_lines_to_preserve = 4; + this.formatterPrefs.blank_lines_at_beginning_of_method_body = ~0; + String input = getCompilationUnit("Formatter", "", "test549249", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test549249", "C_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/549249 - [formatter] Extend Blank Lines settings to remove excess lines + */ +public void testBug549249d() throws JavaModelException { + this.formatterPrefs.number_of_empty_lines_to_preserve = 4; + this.formatterPrefs.blank_lines_before_field = ~3; + String input = getCompilationUnit("Formatter", "", "test549249", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test549249", "D_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/549249 - [formatter] Extend Blank Lines settings to remove excess lines + */ +public void testBug549249e() throws JavaModelException { + this.formatterPrefs.number_of_empty_lines_to_preserve = 4; + this.formatterPrefs.blank_lines_before_first_class_body_declaration = ~2; + String input = getCompilationUnit("Formatter", "", "test549249", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test549249", "E_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/549249 - [formatter] Extend Blank Lines settings to remove excess lines + */ +public void testBug549249f() throws JavaModelException { + this.formatterPrefs.number_of_empty_lines_to_preserve = 4; + this.formatterPrefs.blank_lines_before_imports = ~1; + String input = getCompilationUnit("Formatter", "", "test549249", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test549249", "F_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/549249 - [formatter] Extend Blank Lines settings to remove excess lines + */ +public void testBug549249g() throws JavaModelException { + this.formatterPrefs.number_of_empty_lines_to_preserve = 4; + this.formatterPrefs.blank_lines_before_member_type = ~0; + String input = getCompilationUnit("Formatter", "", "test549249", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test549249", "G_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/549249 - [formatter] Extend Blank Lines settings to remove excess lines + */ +public void testBug549249h() throws JavaModelException { + this.formatterPrefs.number_of_empty_lines_to_preserve = 4; + this.formatterPrefs.blank_lines_before_method = ~3; + String input = getCompilationUnit("Formatter", "", "test549249", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test549249", "H_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/549249 - [formatter] Extend Blank Lines settings to remove excess lines + */ +public void testBug549249i() throws JavaModelException { + this.formatterPrefs.number_of_empty_lines_to_preserve = 4; + this.formatterPrefs.blank_lines_before_new_chunk = ~2; + String input = getCompilationUnit("Formatter", "", "test549249", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test549249", "I_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/549249 - [formatter] Extend Blank Lines settings to remove excess lines + */ +public void testBug549249j() throws JavaModelException { + this.formatterPrefs.number_of_empty_lines_to_preserve = 4; + this.formatterPrefs.blank_lines_before_package = ~1; + String input = getCompilationUnit("Formatter", "", "test549249", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test549249", "J_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/549249 - [formatter] Extend Blank Lines settings to remove excess lines + */ +public void testBug549249k() throws JavaModelException { + this.formatterPrefs.number_of_empty_lines_to_preserve = 4; + this.formatterPrefs.blank_lines_between_import_groups = ~1; + String input = getCompilationUnit("Formatter", "", "test549249", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test549249", "K_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/549249 - [formatter] Extend Blank Lines settings to remove excess lines + */ +public void testBug549249l() throws JavaModelException { + this.formatterPrefs.number_of_empty_lines_to_preserve = 4; + this.formatterPrefs.blank_lines_between_type_declarations = ~3; + String input = getCompilationUnit("Formatter", "", "test549249", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test549249", "L_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/169131 - [formatter] Code formatter: blank lines after last declaration + */ +public void testBug169131a() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.number_of_empty_lines_to_preserve = 3; + this.formatterPrefs.blank_lines_after_last_class_body_declaration = 2; + String input = getCompilationUnit("Formatter", "", "test169131", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test169131", "A_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/169131 - [formatter] Code formatter: blank lines after last declaration + */ +public void testBug169131b() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.number_of_empty_lines_to_preserve = 3; + this.formatterPrefs.blank_lines_after_last_class_body_declaration = ~1; + String input = getCompilationUnit("Formatter", "", "test169131", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test169131", "B_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/169131 - [formatter] Code formatter: blank lines after last declaration + */ +public void testBug169131c() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_9); + this.formatterPrefs.blank_lines_after_last_class_body_declaration = 1; + String input = + "module aaaaaaaaaa.bbbbbbbbbb {\n" + + " requires aaaaaaaaaa.cccccccccc; // a comment\n" + + "}"; + formatSource(input, + "module aaaaaaaaaa.bbbbbbbbbb {\n" + + " requires aaaaaaaaaa.cccccccccc; // a comment\n" + + "\n" + + "}", + CodeFormatter.K_MODULE_INFO | CodeFormatter.F_INCLUDE_COMMENTS); +} +/** + * https://bugs.eclipse.org/169131 - [formatter] Code formatter: blank lines after last declaration + */ +public void testBug169131d() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_9); + this.formatterPrefs.blank_lines_after_last_class_body_declaration = ~0; + String input = + "module aaaaaaaaaa.bbbbbbbbbb {\n" + + " requires aaaaaaaaaa.cccccccccc;\n" + + "\n" + + "}"; + formatSource(input, + "module aaaaaaaaaa.bbbbbbbbbb {\n" + + " requires aaaaaaaaaa.cccccccccc;\n" + + "}", + CodeFormatter.K_MODULE_INFO | CodeFormatter.F_INCLUDE_COMMENTS); +} +/** + * https://bugs.eclipse.org/522089 - [formatter] Provide support for blank line before end of method + */ +public void testBug522089a() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.number_of_empty_lines_to_preserve = 3; + this.formatterPrefs.blank_lines_at_end_of_method_body = 2; + this.formatterPrefs.blank_lines_before_new_chunk = 0; + String input = getCompilationUnit("Formatter", "", "test522089", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test522089", "A_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/522089 - [formatter] Provide support for blank line before end of method + */ +public void testBug522089b() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_8); + this.formatterPrefs.number_of_empty_lines_to_preserve = 3; + this.formatterPrefs.blank_lines_at_end_of_method_body = ~0; + this.formatterPrefs.blank_lines_before_new_chunk = 0; + String input = getCompilationUnit("Formatter", "", "test522089", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test522089", "B_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/549774 - [formatter] Change semantics of Blank lines before member declarations: 'before' -> 'between' + */ +public void testBug549774() throws JavaModelException { + this.formatterPrefs.blank_lines_before_new_chunk = 1; + this.formatterPrefs.blank_lines_before_field = 2; + this.formatterPrefs.blank_lines_before_method = 3; + String input = + "class C {\n" + + " int a;\n" + + " String s;\n" + + " void foo() {}\n" + + " String bar(int a) {}\n" + + "}"; + formatSource(input, + "class C {\n" + + " int a;\n" + + "\n" + + "\n" + + " String s;\n" + + "\n" + + " void foo() {\n" + + " }\n" + + "\n" + + "\n" + + "\n" + + " String bar(int a) {\n" + + " }\n" + + "}"); +} +/** + * https://bugs.eclipse.org/214283 - [formatter] Blank lines option should consider a virtual/interface method + */ +public void testBug214283a() throws JavaModelException { + this.formatterPrefs.blank_lines_before_abstract_method= 2; + this.formatterPrefs.blank_lines_before_method= 0; + String input = getCompilationUnit("Formatter", "", "test214283", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test214283", "A_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/214283 - [formatter] Blank lines option should consider a virtual/interface method + */ +public void testBug214283b() throws JavaModelException { + this.formatterPrefs.blank_lines_before_abstract_method= ~0; + this.formatterPrefs.blank_lines_before_method= 1; + String input = getCompilationUnit("Formatter", "", "test214283", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test214283", "B_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/214283 - [formatter] Blank lines option should consider a virtual/interface method + */ +public void testBug214283c() throws JavaModelException { + this.formatterPrefs.blank_lines_before_abstract_method= 0; + this.formatterPrefs.blank_lines_before_method= 2; + String input = getCompilationUnit("Formatter", "", "test214283", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test214283", "C_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/212867 - [formatter]: Remove blank lines after '{' and before '}' + */ +public void testBug212867a() throws JavaModelException { + this.formatterPrefs.blank_lines_at_beginning_of_code_block = 2; + this.formatterPrefs.blank_lines_at_end_of_code_block = 0; + formatSourceInWorkspace("test212867", "in.java", "A_out.java"); +} +/** + * https://bugs.eclipse.org/212867 - [formatter]: Remove blank lines after '{' and before '}' + */ +public void testBug212867b() throws JavaModelException { + this.formatterPrefs.blank_lines_at_beginning_of_code_block = 0; + this.formatterPrefs.blank_lines_at_end_of_code_block = 2; + formatSourceInWorkspace("test212867", "in.java", "B_out.java"); +} +/** + * https://bugs.eclipse.org/212867 - [formatter]: Remove blank lines after '{' and before '}' + */ +public void testBug212867c() throws JavaModelException { + this.formatterPrefs.blank_lines_at_beginning_of_code_block = 2; + this.formatterPrefs.blank_lines_at_end_of_code_block = 2; + formatSourceInWorkspace("test212867", "in.java", "C_out.java"); +} +/** + * https://bugs.eclipse.org/212867 - [formatter]: Remove blank lines after '{' and before '}' + */ +public void testBug212867d() throws JavaModelException { + this.formatterPrefs.blank_lines_at_beginning_of_code_block = ~0; + this.formatterPrefs.blank_lines_at_end_of_code_block = ~0; + formatSourceInWorkspace("test212867", "in.java", "D_out.java"); +} +/** + * https://bugs.eclipse.org/421492 - [formatter] Allow to add blank line(s) before a statement + */ +public void testBug421492a() throws JavaModelException { + this.formatterPrefs.blank_lines_before_code_block = 2; + this.formatterPrefs.blank_lines_after_code_block = 0; + formatSourceInWorkspace("test421492", "in.java", "A_out.java"); +} +/** + * https://bugs.eclipse.org/421492 - [formatter] Allow to add blank line(s) before a statement + */ +public void testBug421492b() throws JavaModelException { + this.formatterPrefs.blank_lines_before_code_block = 0; + this.formatterPrefs.blank_lines_after_code_block = 2; + formatSourceInWorkspace("test421492", "in.java", "B_out.java"); +} +/** + * https://bugs.eclipse.org/421492 - [formatter] Allow to add blank line(s) before a statement + */ +public void testBug421492c() throws JavaModelException { + this.formatterPrefs.blank_lines_before_code_block = 2; + this.formatterPrefs.blank_lines_after_code_block = 2; + formatSourceInWorkspace("test421492", "in.java", "C_out.java"); +} +/** + * https://bugs.eclipse.org/421492 - [formatter] Allow to add blank line(s) before a statement + */ +public void testBug421492d() throws JavaModelException { + this.formatterPrefs.blank_lines_before_code_block = ~0; + this.formatterPrefs.blank_lines_after_code_block = ~0; + formatSourceInWorkspace("test421492", "in.java", "D_out.java"); +} +/** + * https://bugs.eclipse.org/390720 - [formatter] Add setting for blank line between case blocks (after break) for switch statement + */ +public void testBug390720a() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_14); + this.formatterPrefs.blank_lines_between_statement_groups_in_switch = 2; + formatSourceInWorkspace("test390720", "in.java", "A_out.java"); +} +/** + * https://bugs.eclipse.org/390720 - [formatter] Add setting for blank line between case blocks (after break) for switch statement + */ +public void testBug390720b() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_14); + this.formatterPrefs.blank_lines_between_statement_groups_in_switch = ~0; + formatSourceInWorkspace("test390720", "in.java", "B_out.java"); +} +/** + * https://bugs.eclipse.org/549436 - [13] Formatter support for JEP 355 Text Block + */ +public void testBug549436a() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_15); + setPageWidth80(); + this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE; + this.formatterPrefs.use_tabs_only_for_leading_indentations = false; + this.formatterPrefs.indent_empty_lines = false; + this.formatterPrefs.text_block_indentation = Alignment.M_INDENT_PRESERVE; + this.formatterPrefs.continuation_indentation = 2; + formatSourceInWorkspace("test549436", "in.java", "A_out.java"); +} +/** + * https://bugs.eclipse.org/549436 - [13] Formatter support for JEP 355 Text Block + */ +public void testBug549436b() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_15); + setPageWidth80(); + this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE; + this.formatterPrefs.use_tabs_only_for_leading_indentations = false; + this.formatterPrefs.indent_empty_lines = false; + this.formatterPrefs.text_block_indentation = Alignment.M_INDENT_BY_ONE; + this.formatterPrefs.continuation_indentation = 2; + formatSourceInWorkspace("test549436", "in.java", "B_out.java"); +} +/** + * https://bugs.eclipse.org/549436 - [13] Formatter support for JEP 355 Text Block + */ +public void testBug549436c() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_15); + setPageWidth80(); + this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE; + this.formatterPrefs.use_tabs_only_for_leading_indentations = false; + this.formatterPrefs.indent_empty_lines = false; + this.formatterPrefs.text_block_indentation = Alignment.M_INDENT_DEFAULT; + this.formatterPrefs.continuation_indentation = 2; + formatSourceInWorkspace("test549436", "in.java", "C_out.java"); +} +/** + * https://bugs.eclipse.org/549436 - [13] Formatter support for JEP 355 Text Block + */ +public void testBug549436d() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_15); + setPageWidth80(); + this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE; + this.formatterPrefs.use_tabs_only_for_leading_indentations = false; + this.formatterPrefs.indent_empty_lines = false; + this.formatterPrefs.text_block_indentation = Alignment.M_INDENT_DEFAULT; + this.formatterPrefs.continuation_indentation = 3; + formatSourceInWorkspace("test549436", "in.java", "D_out.java"); +} +/** + * https://bugs.eclipse.org/549436 - [13] Formatter support for JEP 355 Text Block + */ +public void testBug549436e() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_15); + setPageWidth80(); + this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE; + this.formatterPrefs.use_tabs_only_for_leading_indentations = false; + this.formatterPrefs.indent_empty_lines = false; + this.formatterPrefs.text_block_indentation = Alignment.M_INDENT_ON_COLUMN; + this.formatterPrefs.continuation_indentation = 2; + formatSourceInWorkspace("test549436", "in.java", "E_out.java"); +} +/** + * https://bugs.eclipse.org/549436 - [13] Formatter support for JEP 355 Text Block + */ +public void testBug549436f() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_15); + setPageWidth80(); + this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.TAB; + this.formatterPrefs.use_tabs_only_for_leading_indentations = false; + this.formatterPrefs.indent_empty_lines = false; + this.formatterPrefs.text_block_indentation = Alignment.M_INDENT_BY_ONE; + this.formatterPrefs.continuation_indentation = 2; + formatSourceInWorkspace("test549436", "in.java", "F_out.java"); +} +/** + * https://bugs.eclipse.org/549436 - [13] Formatter support for JEP 355 Text Block + */ +public void testBug549436g() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_15); + setPageWidth80(); + this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.TAB; + this.formatterPrefs.use_tabs_only_for_leading_indentations = false; + this.formatterPrefs.indent_empty_lines = true; + this.formatterPrefs.text_block_indentation = Alignment.M_INDENT_DEFAULT; + this.formatterPrefs.continuation_indentation = 2; + formatSourceInWorkspace("test549436", "in.java", "G_out.java"); +} +/** + * https://bugs.eclipse.org/549436 - [13] Formatter support for JEP 355 Text Block + */ +public void testBug549436h() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_15); + setPageWidth80(); + this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.TAB; + this.formatterPrefs.use_tabs_only_for_leading_indentations = true; + this.formatterPrefs.indent_empty_lines = false; + this.formatterPrefs.text_block_indentation = Alignment.M_INDENT_DEFAULT; + this.formatterPrefs.continuation_indentation = 3; + formatSourceInWorkspace("test549436", "in.java", "H_out.java"); +} +/** + * https://bugs.eclipse.org/549436 - [13] Formatter support for JEP 355 Text Block + */ +public void testBug549436i() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_15); + setPageWidth80(); + this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.TAB; + this.formatterPrefs.use_tabs_only_for_leading_indentations = true; + this.formatterPrefs.indent_empty_lines = true; + this.formatterPrefs.text_block_indentation = Alignment.M_INDENT_ON_COLUMN; + this.formatterPrefs.continuation_indentation = 2; + formatSourceInWorkspace("test549436", "in.java", "I_out.java"); +} +/** + * https://bugs.eclipse.org/549436 - [13] Formatter support for JEP 355 Text Block + */ +public void testBug549436j() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_15); + setPageWidth80(); + this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.MIXED; + this.formatterPrefs.use_tabs_only_for_leading_indentations = false; + this.formatterPrefs.indent_empty_lines = false; + this.formatterPrefs.text_block_indentation = Alignment.M_INDENT_ON_COLUMN; + this.formatterPrefs.continuation_indentation = 2; + formatSourceInWorkspace("test549436", "in.java", "J_out.java"); +} +/** + * https://bugs.eclipse.org/549436 - [13] Formatter support for JEP 355 Text Block + */ +public void testBug549436k() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_15); + setPageWidth80(); + this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.TAB; + this.formatterPrefs.use_tabs_only_for_leading_indentations = false; + this.formatterPrefs.indent_empty_lines = false; + this.formatterPrefs.text_block_indentation = Alignment.M_INDENT_ON_COLUMN; + this.formatterPrefs.continuation_indentation = 2; + formatSourceInWorkspace("test549436", "in.java", "K_out.java"); +} +/** + * https://bugs.eclipse.org/54627 - [formatter] Blank lines between Javadoc tags + */ +public void testBug54627a() throws JavaModelException { + this.formatterPrefs.comment_insert_empty_line_between_different_tags = true; + String input = + "public class Test {\n" + + " /**\n" + + " * Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.\n" + + " * @param a Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\n" + + " * @param b Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.\n" + + " * @param c Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n" + + " * @throws IOException Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium.\n" + + " * @throws SQLException Totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.\n" + + " * @return Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.\n" + + " */\n" + + " public String f(int a, int b, int c) throws IOException, SQLException {\n" + + " return \"\";\n" + + " }\n" + + "}"; + formatSource(input, + "public class Test {\n" + + " /**\n" + + " * Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\n" + + " * tempor incididunt ut labore et dolore magna aliqua. Neque porro quisquam est,\n" + + " * qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia\n" + + " * non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam\n" + + " * quaerat voluptatem.\n" + + " * \n" + + " * @param a Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris\n" + + " * nisi ut aliquip ex ea commodo consequat.\n" + + " * @param b Duis aute irure dolor in reprehenderit in voluptate velit esse\n" + + " * cillum dolore eu fugiat nulla pariatur.\n" + + " * @param c Excepteur sint occaecat cupidatat non proident, sunt in culpa qui\n" + + " * officia deserunt mollit anim id est laborum.\n" + + " * \n" + + " * @throws IOException Sed ut perspiciatis unde omnis iste natus error sit\n" + + " * voluptatem accusantium doloremque laudantium.\n" + + " * @throws SQLException Totam rem aperiam, eaque ipsa quae ab illo inventore\n" + + " * veritatis et quasi architecto beatae vitae dicta sunt\n" + + " * explicabo.\n" + + " * \n" + + " * @return Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut\n" + + " * fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem\n" + + " * sequi nesciunt.\n" + + " */\n" + + " public String f(int a, int b, int c) throws IOException, SQLException {\n" + + " return \"\";\n" + + " }\n" + + "}"); +} +/** + * https://bugs.eclipse.org/54627 - [formatter] Blank lines between Javadoc tags + */ +public void testBug54627b() throws JavaModelException { + this.formatterPrefs.comment_insert_empty_line_between_different_tags = true; + String input = + "public class Test {\n" + + " \n" + + " /**\n" + + " * Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.\n" + + " * @param a Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\n" + + " * @param b Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.\n" + + " * @return Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.\n" + + " * @@org.example.transaction.interceptor.RuleBasedTransactionAttribute()\n" + + " * @@org.example.transaction.interceptor.RollbackRuleAttribute(Exception.class)\n" + + " * @@org.example.transaction.interceptor.NoRollbackRuleAttribute(\"ServletException\")\n" + + " */\n" + + " public String f(int a, int b, int c) {\n" + + " return \"\";\n" + + " }\n" + + "}"; + formatSource(input, + "public class Test {\n" + + "\n" + + " /**\n" + + " * Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\n" + + " * tempor incididunt ut labore et dolore magna aliqua. Neque porro quisquam est,\n" + + " * qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia\n" + + " * non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam\n" + + " * quaerat voluptatem.\n" + + " * \n" + + " * @param a Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris\n" + + " * nisi ut aliquip ex ea commodo consequat.\n" + + " * @param b Duis aute irure dolor in reprehenderit in voluptate velit esse\n" + + " * cillum dolore eu fugiat nulla pariatur.\n" + + " * \n" + + " * @return Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut\n" + + " * fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem\n" + + " * sequi nesciunt.\n" + + " * \n" + + " * @@org.example.transaction.interceptor.RuleBasedTransactionAttribute()\n" + + " * @@org.example.transaction.interceptor.RollbackRuleAttribute(Exception.class)\n" + + " * @@org.example.transaction.interceptor.NoRollbackRuleAttribute(\"ServletException\")\n" + + " */\n" + + " public String f(int a, int b, int c) {\n" + + " return \"\";\n" + + " }\n" + + "}"); +} +/** + * https://bugs.eclipse.org/547261 - [formatter] Separate option for space after not (!) operator + */ +public void testBug547261() throws JavaModelException { + this.formatterPrefs.insert_space_after_not_operator = true; + String input = "class C {boolean b=!a&&!(c||d)&&(f!=-5);}"; + formatSource(input, + "class C {\n" + + " boolean b = ! a && ! (c || d) && (f != -5);\n" + + "}"); +} +/** + * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support + */ +public void testBug553155a() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_16); + formatSourceInWorkspace("test553155", "in.java", "A_out.java"); +} +/** + * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support + */ +public void testBug553155b() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_16); + this.formatterPrefs.indent_body_declarations_compare_to_record_header = false; + formatSourceInWorkspace("test553155", "in.java", "B_out.java"); +} +/** + * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support + */ +public void testBug553155c() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_16); + this.formatterPrefs.brace_position_for_record_declaration = DefaultCodeFormatterConstants.NEXT_LINE; + formatSourceInWorkspace("test553155", "in.java", "C_out.java"); +} +/** + * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support + */ +public void testBug553155d() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_16); + this.formatterPrefs.brace_position_for_record_constructor = DefaultCodeFormatterConstants.NEXT_LINE; + formatSourceInWorkspace("test553155", "in.java", "D_out.java"); +} +/** + * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support + */ +public void testBug553155e() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_16); + this.formatterPrefs.parenthesis_positions_in_record_declaration = DefaultCodeFormatterConstants.SEPARATE_LINES; + formatSourceInWorkspace("test553155", "in.java", "E_out.java"); +} +/** + * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support + */ +public void testBug553155f() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_16); + this.formatterPrefs.insert_space_after_comma_in_record_components = false; + formatSourceInWorkspace("test553155", "in.java", "F_out.java"); +} +/** + * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support + */ +public void testBug553155g() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_16); + this.formatterPrefs.insert_space_after_opening_paren_in_record_declaration = true; + formatSourceInWorkspace("test553155", "in.java", "G_out.java"); +} +/** + * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support + */ +public void testBug553155h() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_16); + this.formatterPrefs.insert_space_before_closing_paren_in_record_declaration = true; + formatSourceInWorkspace("test553155", "in.java", "H_out.java"); +} +/** + * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support + */ +public void testBug553155i() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_16); + this.formatterPrefs.insert_space_before_comma_in_record_components = true; + formatSourceInWorkspace("test553155", "in.java", "I_out.java"); +} +/** + * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support + */ +public void testBug553155j() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_16); + this.formatterPrefs.insert_space_before_opening_brace_in_record_constructor = false; + formatSourceInWorkspace("test553155", "in.java", "J_out.java"); +} +/** + * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support + */ +public void testBug553155k() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_16); + this.formatterPrefs.insert_space_before_opening_brace_in_record_declaration = false; + formatSourceInWorkspace("test553155", "in.java", "K_out.java"); +} +/** + * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support + */ +public void testBug553155l() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_16); + this.formatterPrefs.insert_space_before_opening_paren_in_record_declaration = true; + formatSourceInWorkspace("test553155", "in.java", "L_out.java"); +} +/** + * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support + */ +public void testBug553155m() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_16); + this.formatterPrefs.alignment_for_record_components = Alignment.M_ONE_PER_LINE_SPLIT + + Alignment.M_FORCE; + formatSourceInWorkspace("test553155", "in.java", "M_out.java"); +} +/** + * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support + */ +public void testBug553155n() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_16); + this.formatterPrefs.alignment_for_superinterfaces_in_record_declaration = Alignment.M_ONE_PER_LINE_SPLIT + + Alignment.M_FORCE; + formatSourceInWorkspace("test553155", "in.java", "N_out.java"); +} +/** + * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support + */ +public void testBug553155o() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_16); + this.formatterPrefs.keep_record_constructor_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + String source = "record Range(int lo, int hi) {public Range {foo();}}"; + formatSource(source, + "record Range(int lo, int hi) {\n" + + " public Range { foo(); }\n" + + "}"); +} +/** + * https://bugs.eclipse.org/553155 - [14] Records - Formatter Support + */ +public void testBug553155p() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_16); + this.formatterPrefs.keep_record_constructor_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + this.formatterPrefs.keep_record_declaration_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + String source = "record Range(int lo, int hi) {public Range {foo();}}"; + formatSource(source, + "record Range(int lo, int hi) { public Range { foo(); } }"); +} +/** + * https://bugs.eclipse.org/118641 - [formatter] Formatter does not break line on assert statement + * + * Check that assertions are not formatted without enabling the option. + */ +public void testBug118641a() throws JavaModelException { + this.formatterPrefs.alignment_for_assertion_message = Alignment.M_NO_ALIGNMENT; + + String input = + "public class Test {\n" + + "\n" + + " public void f(int a, int b) {\n" + + " assert childElement.getElementsByTagName(FIELD_NAME).getLength() == 1 : \"XML malformed. No attribute name! Please talk to your sysadmin.\";\n" + + " return;\n" + + " }\n" + + "}"; + formatSource(input, + "public class Test {\n" + + "\n" + + " public void f(int a, int b) {\n" + + " assert childElement.getElementsByTagName(FIELD_NAME)\n" + + " .getLength() == 1 : \"XML malformed. No attribute name! Please talk to your sysadmin.\";\n" + + " return;\n" + + " }\n" + + "}"); +} +/** + * https://bugs.eclipse.org/118641 - [formatter] Formatter does not break line on assert statement + * + * + * Check that an assertion is formatted when it exceeds the page width. + */ +public void testBug118641b() throws JavaModelException { + this.formatterPrefs.wrap_before_assertion_message_operator = true; + + String input = + "public class Test {\n" + + " \n" + + " public void f(int a, int b) {\n" + + " assert childElement.getElementsByTagName( FIELD_NAME ).getLength() == 1 : \"XML malformed. No attribute name! Please talk to your sysadmin.\";\n" + + " return;\n" + + " }\n" + + "}"; + formatSource(input, + "public class Test {\n" + + "\n" + + " public void f(int a, int b) {\n" + + " assert childElement.getElementsByTagName(FIELD_NAME).getLength() == 1\n" + + " : \"XML malformed. No attribute name! Please talk to your sysadmin.\";\n" + + " return;\n" + + " }\n" + + "}"); +} +/** + * https://bugs.eclipse.org/118641 - [formatter] Formatter does not break line on assert statement + * + * + * Check that an assertion can be broken after the colon separator. + */ +public void testBug118641c() throws JavaModelException { + this.formatterPrefs.wrap_before_assertion_message_operator = false; + + String input = + "public class Test {\n" + + " \n" + + " public void f(int a, int b) {\n" + + " assert childElement.getElementsByTagName( FIELD_NAME ).getLength() == 1 : \"XML malformed. No attribute name! Please talk to your sysadmin.\";\n" + + " return;\n" + + " }\n" + + "}"; + formatSource(input, + "public class Test {\n" + + "\n" + + " public void f(int a, int b) {\n" + + " assert childElement.getElementsByTagName(FIELD_NAME).getLength() == 1 :\n" + + " \"XML malformed. No attribute name! Please talk to your sysadmin.\";\n" + + " return;\n" + + " }\n" + + "}"); +} +/** + * https://bugs.eclipse.org/118641 - [formatter] Formatter does not break line on assert statement + * + * Check that assertion messages are formatted when the assertion expression exceeds the page width. + */ +public void testBug118641d() throws JavaModelException { + this.formatterPrefs.page_width = 65; + + String input = + "public class Test {\n" + + " \n" + + " public void f(int a, int b) {\n" + + " assert childElement.getElementsByTagName( FIELD_NAME ).getLength() == 1 : \"XML malformed. No attribute name! Please talk to your sysadmin.\";\n" + + " return;\n" + + " }\n" + + "}"; + formatSource(input, + "public class Test {\n" + + "\n" + + " public void f(int a, int b) {\n" + + " assert childElement.getElementsByTagName(FIELD_NAME)\n" + + " .getLength() == 1\n" + + " : \"XML malformed. No attribute name! Please talk to your sysadmin.\";\n" + + " return;\n" + + " }\n" + + "}"); +} +/** + * https://bugs.eclipse.org/118641 - [formatter] Formatter does not break line on assert statement + * + * Check that an assertion message is wrapped when forced to do so. + */ +public void testBug118641e() throws JavaModelException { + this.formatterPrefs.alignment_for_assertion_message = Alignment.M_COMPACT_SPLIT | Alignment.M_FORCE; + + String input = + "public class Test {\n" + + " \n" + + " public void f(int a, int b) {\n" + + " assert childElement.getElementsByTagName( FIELD_NAME ).getLength() == 1 : \"XML malformed. No attribute name!\";\n" + + " return;\n" + + " }\n" + + "}"; + formatSource(input, + "public class Test {\n" + + "\n" + + " public void f(int a, int b) {\n" + + " assert childElement.getElementsByTagName(FIELD_NAME).getLength() == 1\n" + + " : \"XML malformed. No attribute name!\";\n" + + " return;\n" + + " }\n" + + "}"); +} +/** + * https://bugs.eclipse.org/545078 - [formatter] Wrapping settings for annotations + */ +public void testBug545078a() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_5); + formatSourceInWorkspace("test545078", "in.java", "A_out.java"); +} +/** + * https://bugs.eclipse.org/545078 - [formatter] Wrapping settings for annotations + */ +public void testBug545078b() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_5); + this.formatterPrefs.alignment_for_annotations_on_package = Alignment.M_NO_ALIGNMENT; + this.formatterPrefs.insert_new_line_after_annotation_on_type = false; + formatSourceInWorkspace("test545078", "in.java", "B_out.java"); +} +/** + * https://bugs.eclipse.org/545078 - [formatter] Wrapping settings for annotations + */ +public void testBug545078c() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_5); + this.formatterPrefs.alignment_for_annotations_on_package = Alignment.M_COMPACT_SPLIT; + this.formatterPrefs.alignment_for_annotations_on_type = Alignment.M_NO_ALIGNMENT; + this.formatterPrefs.insert_new_line_after_annotation_on_method = false; + formatSourceInWorkspace("test545078", "in.java", "C_out.java"); +} +/** + * https://bugs.eclipse.org/545078 - [formatter] Wrapping settings for annotations + */ +public void testBug545078d() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_5); + this.formatterPrefs.alignment_for_annotations_on_package = Alignment.M_NEXT_PER_LINE_SPLIT; + this.formatterPrefs.alignment_for_annotations_on_type = Alignment.M_COMPACT_FIRST_BREAK_SPLIT; + this.formatterPrefs.alignment_for_annotations_on_method = Alignment.M_NO_ALIGNMENT; + this.formatterPrefs.insert_new_line_after_annotation_on_local_variable = false; + formatSourceInWorkspace("test545078", "in.java", "D_out.java"); +} +/** + * https://bugs.eclipse.org/545078 - [formatter] Wrapping settings for annotations + */ +public void testBug545078e() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_5); + this.formatterPrefs.page_width = 105; + this.formatterPrefs.alignment_for_annotations_on_method = Alignment.M_COMPACT_SPLIT; + this.formatterPrefs.alignment_for_annotations_on_local_variable = Alignment.M_NO_ALIGNMENT; + this.formatterPrefs.insert_new_line_after_annotation_on_field = false; + formatSourceInWorkspace("test545078", "in.java", "E_out.java"); +} +/** + * https://bugs.eclipse.org/545078 - [formatter] Wrapping settings for annotations + */ +public void testBug545078f() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_5); + this.formatterPrefs.page_width= 95; + this.formatterPrefs.alignment_for_annotations_on_local_variable = Alignment.M_COMPACT_SPLIT; + this.formatterPrefs.alignment_for_annotations_on_field = Alignment.M_NO_ALIGNMENT; + this.formatterPrefs.insert_new_line_after_annotation_on_parameter = true; + formatSourceInWorkspace("test545078", "in.java", "F_out.java"); +} +/** + * https://bugs.eclipse.org/545078 - [formatter] Wrapping settings for annotations + */ +public void testBug545078g() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_5); + this.formatterPrefs.alignment_for_annotations_on_field = Alignment.M_COMPACT_SPLIT; + this.formatterPrefs.alignment_for_annotations_on_parameter = Alignment.M_ONE_PER_LINE_SPLIT; + this.formatterPrefs.insert_new_line_after_type_annotation = true; + formatSourceInWorkspace("test545078", "in.java", "G_out.java"); +} +/** + * https://bugs.eclipse.org/545078 - [formatter] Wrapping settings for annotations + */ +public void testBug545078h() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_5); + this.formatterPrefs.page_width = 105; + this.formatterPrefs.alignment_for_annotations_on_parameter = Alignment.M_COMPACT_SPLIT; + this.formatterPrefs.alignment_for_type_annotations = Alignment.M_ONE_PER_LINE_SPLIT; + this.formatterPrefs.insert_new_line_after_annotation_on_package = false; + formatSourceInWorkspace("test545078", "in.java", "H_out.java"); +} +/** + * https://bugs.eclipse.org/545078 - [formatter] Wrapping settings for annotations + */ +public void testBug545078i() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_5); + this.formatterPrefs.page_width = 105; + this.formatterPrefs.alignment_for_type_annotations = Alignment.M_COMPACT_SPLIT; + this.formatterPrefs.alignment_for_annotations_on_enum_constant = Alignment.M_NO_ALIGNMENT; + this.formatterPrefs.insert_new_line_after_annotation_on_enum_constant = false; + formatSourceInWorkspace("test545078", "in.java", "I_out.java"); +} +/** + * https://bugs.eclipse.org/545078 - [formatter] Wrapping settings for annotations + */ +public void testBug545078j() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_1_5); + this.formatterPrefs.page_width = 80; + this.formatterPrefs.alignment_for_annotations_on_package = Alignment.M_COMPACT_SPLIT; + this.formatterPrefs.alignment_for_annotations_on_type = Alignment.M_COMPACT_SPLIT; + this.formatterPrefs.alignment_for_annotations_on_method = Alignment.M_COMPACT_SPLIT; + this.formatterPrefs.alignment_for_annotations_on_field = Alignment.M_COMPACT_SPLIT; + this.formatterPrefs.alignment_for_annotations_on_parameter = Alignment.M_COMPACT_SPLIT; + this.formatterPrefs.alignment_for_annotations_on_local_variable = Alignment.M_COMPACT_SPLIT; + this.formatterPrefs.alignment_for_type_annotations = Alignment.M_COMPACT_SPLIT; + this.formatterPrefs.alignment_for_annotations_on_enum_constant = Alignment.M_COMPACT_SPLIT; + formatSourceInWorkspace("test545078", "in.java", "J_out.java"); +} + +/** + * https://bugs.eclipse.org/222083 - [formatter] Formatting bug for GWT code + */ +public void testBug222083() { + String source = + "class C {\n" + + " private static native void redirect(String url)/*-{\n" + + " $wnd.location = url;\n" + + " }-*/;\n" + + "}"; + formatSource(source); +} + +/** + * Bug 567016 - [formatter] off/on tags: enable by default + */ +public void testBug567016() { + this.formatterPrefs.use_tags = false; + String source = + "public class X01 {\n" + + "\n" + + "/* @formatter:off */\n" + + "void foo( ) { \n" + + " // unformatted comment\n" + + "}\n" + + "/* @formatter:on */\n" + + "void bar( ) { \n" + + " // formatted comment\n" + + "}\n" + + "}\n"; + formatSource(source, + "public class X01 {\n" + + "\n" + + " /* @formatter:off */\n" + + " void foo() {\n" + + " // unformatted comment\n" + + " }\n" + + "\n" + + " /* @formatter:on */\n" + + " void bar() {\n" + + " // formatted comment\n" + + " }\n" + + "}\n" + ); +} + +/** + * https://bugs.eclipse.org/573949 - [17][switch pattern][formatter] JEP 406 changes + */ +public void testBug573949() { + setComplianceLevel(CompilerOptions.VERSION_21); + this.formatterOptions.put(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED); + String source = + "public class X {\n" + + " private static void foo(Object o) {\n" + + " switch (o) {\n" + + " case Integer t, String : System.out.println(\"Error should be flagged for Integer and String\");\n" + + " default : System.out.println(\"Object\");\n" + + " }\n" + + " }\n" + + "\n" + + "static void testTriangle(Shape s) {\n" + + " switch (s) {\n" + + " case Triangle t when t.calculateArea() > 100 ->\n" + + " System.out.println(\"Large triangle\");\n" + + " default ->\n" + + " System.out.println(\"A shape, possibly a small triangle\");\n" + + " }\n" + + "}\n" + + "}"; + formatSource(source, + "public class X {\n" + + " private static void foo(Object o) {\n" + + " switch (o) {\n" + + " case Integer t, String:\n" + + " System.out.println(\"Error should be flagged for Integer and String\");\n" + + " default:\n" + + " System.out.println(\"Object\");\n" + + " }\n" + + " }\n" + + "\n" + + " static void testTriangle(Shape s) {\n" + + " switch (s) {\n" + + " case Triangle t when t.calculateArea() > 100 -> System.out.println(\"Large triangle\");\n" + + " default -> System.out.println(\"A shape, possibly a small triangle\");\n" + + " }\n" + + " }\n" + + "}" + ); +} + +/** + * https://bugs.eclipse.org/576373 - [formatting] Add formatting setting for whitespace in permits clause + */ +public void testBug576373() { + setComplianceLevel(CompilerOptions.VERSION_17); + String source = + "public sealed class X permits Y, Z {\n" + + "}"; + formatSource(source); +} + +/** + * https://bugs.eclipse.org/577117 - [formatter] Wrong indentation for method invocation on multi-line expression + */ +public void testBug577117a() { + this.formatterPrefs.page_width = 55; + this.formatterPrefs.align_selector_in_method_invocation_on_expression_first_line = false; + String source = + "class Example {\n" + + " String foo() {\n" + + " return new StringBuilder(Arrays.asList(11111111, 22222222, 3333333, 44444444)).append(\"TextTextText\").append(11111111 + 2222222 + 33333333).toStrinig();\n" + + " }\n" + + "}"; + formatSource(source, + "class Example {\n" + + " String foo() {\n" + + " return new StringBuilder(Arrays.asList(\n" + + " 11111111, 22222222, 3333333, 44444444))\n" + + " .append(\"TextTextText\")\n" + + " .append(11111111 + 2222222\n" + + " + 33333333)\n" + + " .toStrinig();\n" + + " }\n" + + "}"); +} +/** + * https://bugs.eclipse.org/577117 - [formatter] Wrong indentation for method invocation on multi-line expression + */ +public void testBug577117b() { + this.formatterPrefs.page_width = 53; + String source = + "class Example {\n" + + " String foo() {\n" + + " return new StringBuilder(Arrays.asList(11111111, 22222222, 3333333, 444444)).append(\"TextTextText\").append(11111111 + 2222222 + 33333333).toStrinig();\n" + + " }\n" + + "}"; + formatSource(source, + "class Example {\n" + + " String foo() {\n" + + " return new StringBuilder(Arrays.asList(\n" + + " 11111111, 22222222, 3333333, 444444))\n" + + " .append(\"TextTextText\")\n" + + " .append(11111111 + 2222222\n" + + " + 33333333)\n" + + " .toStrinig();\n" + + " }\n" + + "}"); +} + +/** + * https://bugs.eclipse.org/578044 - [Formatter] Case statement in switch expression is not line wrapped + */ +public void testBug578044a() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_14); + this.formatterPrefs.page_width = 60; + String input = getCompilationUnit("Formatter", "", "test578044", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test578044", "A_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/578044 - [Formatter] Case statement in switch expression is not line wrapped + */ +public void testBug578044b() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_14); + this.formatterPrefs.page_width = 60; + this.formatterPrefs.alignment_for_switch_case_with_arrow = Alignment.M_COMPACT_SPLIT + Alignment.M_INDENT_DEFAULT; + String input = getCompilationUnit("Formatter", "", "test578044", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test578044", "B_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/578044 - [Formatter] Case statement in switch expression is not line wrapped + */ +public void testBug578044c() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_14); + this.formatterPrefs.page_width = 60; + this.formatterPrefs.alignment_for_switch_case_with_arrow = Alignment.M_COMPACT_SPLIT + Alignment.M_INDENT_DEFAULT + + Alignment.M_FORCE; + this.formatterPrefs.wrap_before_switch_case_arrow_operator = true; + String input = getCompilationUnit("Formatter", "", "test578044", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test578044", "C_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/578044 - [Formatter] Case statement in switch expression is not line wrapped + */ +public void testBug578044d() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_14); + this.formatterPrefs.page_width = 60; + this.formatterPrefs.alignment_for_expressions_in_switch_case_with_arrow = Alignment.M_NEXT_PER_LINE_SPLIT + Alignment.M_INDENT_BY_ONE; + String input = getCompilationUnit("Formatter", "", "test578044", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test578044", "D_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/578044 - [Formatter] Case statement in switch expression is not line wrapped + */ +public void testBug578044e() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_14); + this.formatterPrefs.page_width = 60; + this.formatterPrefs.alignment_for_expressions_in_switch_case_with_colon = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_INDENT_ON_COLUMN; + String input = getCompilationUnit("Formatter", "", "test578044", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test578044", "E_out.java").getSource()); +} + +/** + * https://bugs.eclipse.org/578361 - [formatter] Keep braced code on one line: settings for new switch constructs + */ +public void testBug578361a() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_14); + this.formatterPrefs.page_width = 80; + this.formatterPrefs.keep_switch_case_with_arrow_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + String input = getCompilationUnit("Formatter", "", "test578361", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test578361", "A_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/578361 - [formatter] Keep braced code on one line: settings for new switch constructs + */ +public void testBug578361b() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_14); + this.formatterPrefs.page_width = 80; + this.formatterPrefs.keep_switch_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + String input = getCompilationUnit("Formatter", "", "test578361", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test578361", "B_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/578361 - [formatter] Keep braced code on one line: settings for new switch constructs + */ +public void testBug578361c() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_14); + this.formatterPrefs.keep_switch_case_with_arrow_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + this.formatterPrefs.keep_switch_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + String input = getCompilationUnit("Formatter", "", "test578361", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test578361", "C_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/578361 - [formatter] Keep braced code on one line: settings for new switch constructs + */ +public void testBug578361d() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_14); + this.formatterPrefs.keep_switch_case_with_arrow_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM; + this.formatterPrefs.keep_switch_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM; + String input = getCompilationUnit("Formatter", "", "test578361", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test578361", "D_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/578361 - [formatter] Keep braced code on one line: settings for new switch constructs + */ +public void testBug578361e() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_14); + this.formatterPrefs.page_width = 55; + this.formatterPrefs.keep_switch_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + this.formatterPrefs.keep_switch_case_with_arrow_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + this.formatterPrefs.alignment_for_switch_case_with_arrow = Alignment.M_COMPACT_SPLIT + Alignment.M_INDENT_BY_ONE; + String input = getCompilationUnit("Formatter", "", "test578361", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test578361", "E_out.java").getSource()); +} +/** + * https://bugs.eclipse.org/578361 - [formatter] Keep braced code on one line: settings for new switch constructs + */ +public void testBug578361f() throws JavaModelException { + setComplianceLevel(CompilerOptions.VERSION_14); + this.formatterPrefs.page_width = 55; + this.formatterPrefs.keep_switch_body_block_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + this.formatterPrefs.keep_switch_case_with_arrow_on_one_line = DefaultCodeFormatterConstants.ONE_LINE_ALWAYS; + this.formatterPrefs.alignment_for_switch_case_with_arrow = Alignment.M_NO_ALIGNMENT; + String input = getCompilationUnit("Formatter", "", "test578361", "in.java").getSource(); + formatSource(input, getCompilationUnit("Formatter", "", "test578361", "F_out.java").getSource()); +} +/** + * https://github.com/eclipse-jdt/eclipse.jdt.core/issues/264 - [19] Formatter support for JEP 405: Record Patterns + */ +public void testIssue264a() { + setComplianceLevel(CompilerOptions.VERSION_21); + this.formatterOptions.put(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED); + String source = + "public class X{int baz(Bar bar){return switch(bar){\n" + + " case Bar(Foo(var a,var b),Foo(var c,var d))->a+b+c+d;\n" + + "};}}"; + formatSource(source, + "public class X {\n" + + " int baz(Bar bar) {\n" + + " return switch (bar) {\n" + + " case Bar(Foo(var a, var b), Foo(var c, var d)) -> a + b + c + d;\n" + + " };\n" + + " }\n" + + "}"); +} +/** + * https://github.com/eclipse-jdt/eclipse.jdt.core/issues/264 - [19] Formatter support for JEP 405: Record Patterns + */ +public void testIssue264b() { + setComplianceLevel(CompilerOptions.VERSION_21); + this.formatterOptions.put(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED); + this.formatterPrefs.insert_space_before_comma_in_record_components = false; + this.formatterPrefs.insert_space_after_comma_in_record_components = false; + this.formatterPrefs.insert_space_before_opening_paren_in_record_declaration = true; + this.formatterPrefs.insert_space_after_opening_paren_in_record_declaration = true; + this.formatterPrefs.insert_space_before_closing_paren_in_record_declaration = true; + String source = + "public class X{int baz(Bar bar){return switch(bar){\n" + + " case Bar(Foo(var a,var b),Foo(var c,var d))->a+b+c+d;\n" + + "};}}"; + formatSource(source, + "public class X {\n" + + " int baz(Bar bar) {\n" + + " return switch (bar) {\n" + + " case Bar ( Foo ( var a,var b ),Foo ( var c,var d ) ) -> a + b + c + d;\n" + + " };\n" + + " }\n" + + "}"); +} +/** + * https://bugs.eclipse.org/564052 - [15] JEP 360 - Sealed Types -Formatter Support + */ +public void testBug564052() { + setComplianceLevel(CompilerOptions.VERSION_17); + this.formatterPrefs.alignment_for_permitted_types_in_type_declaration = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE; + String source = + "sealed class Example permits C1, C2, C3 {}"; + formatSource(source, + "sealed class Example\n" + + " permits\n" + + " C1,\n" + + " C2,\n" + + " C3 {\n" + + "}"); +} + +/** + * https://github.com/eclipse-jdt/eclipse.jdt/issues/59 - Formatter support for guard expressions + */ +public void testGH59() { + setComplianceLevel(CompilerOptions.VERSION_21); + + String source = + """ + public class JunkClass { + Object myObj; + + void foo() { + when(myObj); + foo(myObj); + foo(myObj); + } + + void foo( Object stuff ) {} + void when( Object methodCall ) {} + } + """; + formatSource(source, + """ + public class JunkClass { + Object myObj; + + void foo() { + when(myObj); + foo(myObj); + foo(myObj); + } + + void foo(Object stuff) { + } + + void when(Object methodCall) { + } + } + """); +} + +} diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java index 29b4fd42ecd..e8d4391cd0c 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java @@ -1,3113 +1,3113 @@ -/******************************************************************************* - * Copyright (c) 2014, 2016 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - * Stephan Herrmann - Contribution for - * Bug 377883 - NPE on open Call Hierarchy - *******************************************************************************/ - -package org.eclipse.jdt.core.tests.model; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintStream; -import java.io.UnsupportedEncodingException; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Enumeration; -import java.util.LinkedList; -import java.util.List; -import java.util.Scanner; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jdt.core.IAccessRule; -import org.eclipse.jdt.core.IClasspathAttribute; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IField; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IMethod; -import org.eclipse.jdt.core.IParent; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.ToolFactory; -import org.eclipse.jdt.core.search.IJavaSearchConstants; -import org.eclipse.jdt.core.search.IJavaSearchScope; -import org.eclipse.jdt.core.search.MethodNameMatch; -import org.eclipse.jdt.core.search.MethodNameMatchRequestor; -import org.eclipse.jdt.core.search.SearchEngine; -import org.eclipse.jdt.core.search.SearchMatch; -import org.eclipse.jdt.core.search.SearchParticipant; -import org.eclipse.jdt.core.search.SearchPattern; -import org.eclipse.jdt.core.search.TypeNameMatch; -import org.eclipse.jdt.core.search.TypeNameMatchRequestor; -import org.eclipse.jdt.core.util.ClassFileBytesDisassembler; -import org.eclipse.jdt.internal.core.search.matching.MatchLocator; -import org.eclipse.jdt.internal.core.search.matching.MethodPattern; -import org.eclipse.osgi.service.environment.Constants; - -import junit.framework.Test; - -// The size of JavaSearchBugsTests.java is very big, Hence continuing here. -@SuppressWarnings({"rawtypes", "unchecked"}) -public class JavaSearchBugsTests2 extends AbstractJavaSearchTests { - - public JavaSearchBugsTests2(String name) { - super(name); - this.endChar = ""; - } - - static { - //TESTS_NAMES = new String[] {"testBug378390"}; - } - - public static Test suite() { - return buildModelTestSuite(JavaSearchBugsTests2.class); - } - - class TestCollector extends JavaSearchResultCollector { - public List matches = new ArrayList(); - - @Override - public void acceptSearchMatch(SearchMatch searchMatch) throws CoreException { - super.acceptSearchMatch(searchMatch); - this.matches.add(searchMatch); - } - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - this.resultCollector = new TestCollector(); - this.resultCollector.showAccuracy(true); - } - - /** - * Test that missing types in the class shouldn't impact the search of a type in an inner class - */ - public void testBug362633() throws CoreException, IOException { - try { - IJavaProject p = createJavaProject("P", new String[] {}, new String[] { "/P/lib325418.jar", "JCL15_LIB" }, "", "1.5"); - org.eclipse.jdt.core.tests.util.Util.createJar(new String[] { - "p325418M/Missing.java", - "package p325418M;\n" + - "public class Missing{}\n" }, - p.getProject().getLocation().append("lib325418M.jar").toOSString(), "1.5"); - - org.eclipse.jdt.core.tests.util.Util.createJar( - new String[] { - "p325418/Test.java", - "package p325418;\n" + - "public class Test{\n" + - " public void foo(p325418M.Missing a) {}\n" + - " public T foo(int a) {\n" + - " return new Inner() {T run() { return null; }}.run();\n" + - " }\n" + "}\n", - "p325418/Inner.java", - "package p325418;\n" + - "abstract class Inner {\n" + - " abstract T run();\n" + "}\n" }, - null, - p.getProject().getLocation().append("lib325418.jar").toOSString(), - new String[] { p.getProject().getLocation().append("lib325418M.jar").toOSString() }, - "1.5"); - refresh(p); - int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES; - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, mask); - search("Inner.run()", IJavaSearchConstants.METHOD, IJavaSearchConstants.DECLARATIONS, scope, this.resultCollector); - assertSearchResults( - "Unexpected search results!", - "lib325418.jar T p325418.Inner.run() [No source] EXACT_MATCH\n" + - "lib325418.jar T p325418..run() [No source] EXACT_MATCH", - this.resultCollector); - } finally { - deleteProject("P"); - } - } - - /** - * @bug 123836: [1.5][search] for references to overriding method with bound type variable is not polymorphic - * @test Search for references to an overridden method with bound variables should yield. - * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=123836" - */ - public void testBug123836a() throws CoreException { - IJavaProject project = null; - try - { - project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); - createFile("/P/Sub.java", - "abstract class Sup {\n" + - " protected void m(C classifier) {}\n"+ - " public void use(C owner) { m (owner); }\n" + - "}\n" + - "public class Sub extends Sup{\n" + - " @Override\n"+ - " protected void m(String classifier) {}\n"+ - "}\n"); - IType type = getCompilationUnit("/P/Sub.java").getType("Sub"); - IMethod method = type.getMethod("m", new String[]{"QString;"}); - search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults("Sub.java void Sup.use(C) [m (owner)] EXACT_MATCH"); - } finally { - deleteProject(project); - } - } - // Search for a non-overridden method with same name as which could have been overridden should - // not have results - public void testBug123836b() throws CoreException { - IJavaProject project = null; - try - { - project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); - createFile("/P/Sub.java", - "abstract class Sup {\n" + - " protected void m(C classifier) {}\n"+ - " public void use(C owner) { m (owner); }\n" + - "}\n" + - "public class Sub extends Sup{\n" + - " @Override\n"+ - " protected void m(String classifier) {}\n"+ - " protected void m(Sub classifier) {}\n"+ - "}\n" ); - // search - IType type = getCompilationUnit("/P/Sub.java").getType("Sub"); - IMethod method = type.getMethod("m", new String[]{"QSub;"}); - search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults(""); - - } finally { - deleteProject(project); - } - } - // another variant of the testcase - public void testBug123836c() throws CoreException { - IJavaProject project = null; - try - { - // create the common project and create an interface - project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); - createFile("/P/Test.java", - "class Test {\n"+ - " void calc(Property prop, Property p2) {\n"+ - " prop.compute(null);\n"+ - " p2.compute(null);\n"+ - " }\n"+ - "}\n"+ - "abstract class Property {\n"+ - " public abstract void compute(E e);\n"+ - "}\n"+ - "class StringProperty extends Property {\n"+ - " @Override public void compute(String e) {\n"+ - " System.out.println(e);\n"+ - " }"); - IType type = getCompilationUnit("/P/Test.java").getType("StringProperty"); - IMethod method = type.getMethod("compute", new String[]{"QString;"}); - search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults("Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH\n" + - "Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH"); - } finally { - deleteProject(project); - } - } - // Test inner class - public void testBug123836d() throws CoreException { - IJavaProject project = null; - try - { - // create the common project and create an interface - project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); - createFile("/P/Test.java", - "class Test {\n"+ - " void calc(Property prop, Property p2) {\n"+ - " prop.compute(null);\n"+ - " p2.compute(null);\n"+ - " }\n"+ - " class StringProperty extends Property {\n"+ - " @Override public void compute(String e) {\n"+ - " System.out.println(e);\n"+ - " }\n"+ - "}\n"+ - "abstract class Property {\n"+ - " public abstract void compute(E e);\n"+ - "}"); - - IType type = getCompilationUnit("/P/Test.java").getType("Test").getType("StringProperty"); - IMethod method = type.getMethod("compute", new String[]{"QString;"}); - search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults("Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH\n" + - "Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH"); - } finally { - deleteProject(project); - } - } - // Test local class - public void testBug123836e() throws CoreException { - IJavaProject project = null; - try - { - // create the common project and create an interface - project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); - createFile("/P/Test.java", - "class Test {\n"+ - " void calc(Property prop, Property p2) {\n"+ - " prop.compute(null);\n"+ - " p2.compute(null);\n"+ - " class StringProperty extends Property {\n"+ - " @Override public void compute(String e) {\n"+ - " System.out.println(e);\n"+ - " }\n"+ - " }\n"+ - " }\n"+ - "}\n"+ - "abstract class Property {\n"+ - " public abstract void compute(E e);\n"+ - "}"); - IMethod method = selectMethod(getCompilationUnit("/P/Test.java"), "compute", 3); - search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults("Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH\n" + - "Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH"); - } finally { - deleteProject(project); - } - } - // test inner class - public void testBug123836f() throws CoreException { - IJavaProject project = null; - try - { - // create the common project and create an interface - project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); - createFile("/P/Test.java", - "class Test {\n"+ - " void calc(Property prop, Property p2) {\n"+ - " prop.compute(null);\n"+ - " p2.compute(null);\n"+ - " new Property() {\n"+ - " @Override public void compute(String e) {\n"+ - " System.out.println(e);\n"+ - " }\n"+ - " };\n"+ - " }\n"+ - "}\n"+ - "abstract class Property {\n"+ - " public abstract void compute(E e);\n"+ - "}"); - IMethod method = selectMethod(getCompilationUnit("/P/Test.java"), "compute", 3); - search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults("Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH\n" + - "Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH"); - } finally { - deleteProject(project); - } - } - // test in initializer block - public void testBug123836g() throws CoreException { - IJavaProject project = null; - try - { - // create the common project and create an interface - project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); - createFile("/P/Test.java", - "class Test {\n"+ - " {\n" + - " new Property() {\n" + - " @Override public void compute(String e) {}\n" + - " };\n"+ - " }\n"+ - " void calc(Property prop, Property p2) {\n"+ - " prop.compute(null);\n"+ - " p2.compute(null);\n"+ - " }\n"+ - "}\n"+ - "abstract class Property {\n"+ - " public abstract void compute(E e);\n"+ - "}"); - IMethod method = selectMethod(getCompilationUnit("/P/Test.java"), "compute", 1); - search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults("Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH\n" + - "Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH"); - } finally { - deleteProject(project); - } - } - // test in static initializer - public void testBug123836h() throws CoreException { - IJavaProject project = null; - try - { - // create the common project and create an interface - project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); - createFile("/P/Test.java", - "class Test {\n"+ - " static {\n" + - " new Property() {\n" + - " @Override public void compute(String e) {}\n" + - " };\n"+ - " }\n"+ - " void calc(Property prop, Property p2) {\n"+ - " prop.compute(null);\n"+ - " p2.compute(null);\n"+ - " }\n"+ - "}\n"+ - "abstract class Property {\n"+ - " public abstract void compute(E e);\n"+ - "}"); - IMethod method = selectMethod(getCompilationUnit("/P/Test.java"), "compute", 1); - search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults("Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH\n" + - "Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH"); - } finally { - deleteProject(project); - } - } - // test in static initializer - public void testBug123836i() throws CoreException { - IJavaProject project = null; - try - { - // create the common project and create an interface - project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); - createFile("/P/Test.java", - "class Test {\n"+ - " Property p = new Property() {\n" + - " @Override public void compute(String e) {}\n" + - " };\n"+ - " void calc(Property prop, Property p2) {\n"+ - " prop.compute(null);\n"+ - " p2.compute(null);\n"+ - " }\n"+ - "}\n"+ - "abstract class Property {\n"+ - " public abstract void compute(E e);\n"+ - "}"); - IMethod method = selectMethod(getCompilationUnit("/P/Test.java"), "compute", 1); - search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults("Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH\n" + - "Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH"); - } finally { - deleteProject(project); - } - } - public void testBug123836j() throws CoreException { - IJavaProject project = null; - try - { - // create the common project and create an interface - project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); - createFile("/P/Test.java", - "class Test {\n"+ - " void calc(Property prop, Property p2) {\n"+ - " prop.compute(null);\n"+ - " p2.compute(null);\n"+ - " }\n"+ - "}\n"+ - "abstract class Property {\n"+ - " public abstract void compute(E e);\n"+ - "}\n"+ - "class StringProperty extends Property {\n"+ - " @Override public void compute(String e) {\n"+ - " new Property() {\n"+ - " @Override public void compute(String e) {\n"+ - " new Property() {\n"+ - " @Override public void compute(String e) {}\n"+ - " };\n"+ - " }\n"+ - " };\n"+ - " }\n"+ - "}"); - IMethod method = selectMethod(getCompilationUnit("/P/Test.java"), "compute", 6); - search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults("Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH\n" + - "Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH"); - } finally { - deleteProject(project); - } - } - // test search of name - public void _testBug123836g1() throws CoreException { - IJavaProject project = null; - try - { - // create the common project and create an interface - project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); - createFile("/P/Sub.java", - "abstract class Sup {\n" + - " protected void m(C classifier) {}\n"+ - " public void use(C owner) { m (owner); }\n" + - "}\n" + - "public class Sub extends Sup{\n" + - " @Override\n"+ - " protected void m(String classifier) {}\n"+ - " protected void m(Sub classifier) {}\n"+ - "}\n" ); - waitUntilIndexesReady(); - // search - SearchPattern pattern = SearchPattern.createPattern("Sub.m(String)", METHOD, REFERENCES, EXACT_RULE); - search(pattern, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults("Sub.java void Sup.use(C) [m (owner)] EXACT_MATCH"); - - } finally { - deleteProject(project); - } - } - // test search of name (negative) - public void _testBug123836h1() throws CoreException { - IJavaProject project = null; - try - { - // create the common project and create an interface - project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); - createFile("/P/Sub.java", - "abstract class Sup {\n" + - " protected void m(C classifier) {}\n"+ - " public void use(C owner) { m (owner); }\n" + - "}\n" + - "public class Sub extends Sup{\n" + - " @Override\n"+ - " protected void m(String classifier) {}\n"+ - " protected void m(Sub classifier) {}\n"+ - "}\n" ); - // search - SearchPattern pattern = SearchPattern.createPattern("Sub.m(Sub)", METHOD, REFERENCES, EXACT_RULE); - search(pattern, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults(""); - - } finally { - deleteProject(project); - } - } - /** - * @bug 297825: [search] Rename refactoring doesn't update enclosing type - * @test Search for references for enclosing type's subclass should return a match. - * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=297825" - */ - public void testBug297825a() throws CoreException { - try { - IJavaProject p = createJavaProject("P", new String[] { "src" }, - new String[] {"JCL_LIB"}, "bin"); - createFolder("/P/src/b297825"); - createFile("/P/src/b297825/_Foo.java", - "package b297825;\n" + - "public class _Foo {\n" + - " public static class Bar {\n" + - " }\n" + - "}" - ); - createFile("/P/src/b297825/Foo.java", - "package b297825;\n" + - "public class Foo extends _Foo {\n" + - "}\n" - ); - createFile("/P/src/b297825/Main.java", - "package b297825;\n" + - "public class Main {\n" + - " public static void main(String[] args) {\n" + - " new Foo.Bar();\n" + - " }\n" + - "}" - ); - waitUntilIndexesReady(); - IType type = getCompilationUnit("/P/src/b297825/Foo.java").getType("Foo"); - IJavaSearchScope scope = SearchEngine - .createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES); - - search(type, REFERENCES, scope, this.resultCollector); - - assertSearchResults("src/b297825/Main.java void b297825.Main.main(String[]) [Foo] EXACT_MATCH"); - } finally { - deleteProject("P"); - } - } - /** - * @bug 297825: [search] Rename refactoring doesn't update enclosing type - * @test Verify there is no AIOOB when searching for references for a type. - * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=297825" - */ - public void testBug297825b() throws CoreException { - try { - IJavaProject p = createJavaProject("P", new String[] { "src" }, - new String[] {"JCL_LIB"}, "bin"); - createFile("/P/src/Foo.java", - "class _Foo {\n" + - " public static class Bar {\n" + - " }\n" + - "}" + - "public class Foo extends _Foo {\n" + - " public static class FooBar {\n" + - " }\n" + - "}" + - "class Main {\n" + - " public static void main(String[] args) {\n" + - " new Foo.Bar();\n" + - " new Foo.FooBar();\n" + - " }\n" + - "}" - ); - waitUntilIndexesReady(); - IType type = getCompilationUnit("/P/src/Foo.java").getType("Foo"); - IJavaSearchScope scope = SearchEngine - .createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES); - - search(type, REFERENCES, scope, this.resultCollector); - - assertSearchResults("src/Foo.java void Main.main(String[]) [Foo] EXACT_MATCH\n" + - "src/Foo.java void Main.main(String[]) [Foo] EXACT_MATCH"); - } finally { - deleteProject("P"); - } - } - /** - * @bug 297825: [search] Rename refactoring doesn't update enclosing type - * @test Search for references for the top level type Foo should report no match. "new _Foo.Bar.Foo()" refers to a different type. - * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=297825" - */ - public void testBug297825c() throws CoreException { - try { - IJavaProject p = createJavaProject("P", new String[] { "src" }, - new String[] {"JCL_LIB"}, "bin"); - createFolder("/P/src/b297825"); - createFile("/P/src/b297825/_Foo.java", - "package b297825;\n" + - "public class _Foo {\n" + - " public static class Bar {\n" + - " public static class Foo {\n" + - " }\n" + - " }\n" + - "}" - ); - createFile("/P/src/b297825/Foo.java", - "package b297825;\n" + - "public class Foo extends _Foo {\n" + - "}" - ); - createFile("/P/src/b297825/Main.java", - "package b297825;\n" + - "class Main {\n" + - " public static void main(String[] args) {\n" + - " new _Foo.Bar.Foo();\n" + - " }\n" + - "}" - ); - waitUntilIndexesReady(); - IType type = getCompilationUnit("/P/src/b297825/Foo.java").getType("Foo"); - IJavaSearchScope scope = SearchEngine - .createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES); - - search(type, REFERENCES, scope, this.resultCollector); - - assertSearchResults(""); - } finally { - deleteProject("P"); - } - } - /** - * @bug 297825: [search] Rename refactoring doesn't update enclosing type - * @test Search for references for enclosing type's subclass should return a match. The inner type is parameterized. - * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=297825" - */ - public void testBug297825d() throws CoreException { - try { - IJavaProject p = createJavaProject("P", new String[] { "src" }, - new String[] {"JCL_LIB"}, "bin"); - createFolder("/P/src/b297825"); - createFile("/P/src/b297825/_Foo.java", - "package b297825;\n" + - "public class _Foo {\n" + - " public static class Bar {\n" + - " }\n" + - "}" - ); - createFile("/P/src/b297825/Foo.java", - "package b297825;\n" + - "public class Foo extends _Foo {\n" + - "}\n" - ); - createFile("/P/src/b297825/Main.java", - "package b297825;\n" + - "public class Main {\n" + - " public static void main(String[] args) {\n" + - " new Foo.Bar();\n" + - " }\n" + - "}" - ); - waitUntilIndexesReady(); - IType type = getCompilationUnit("/P/src/b297825/Foo.java").getType("Foo"); - IJavaSearchScope scope = SearchEngine - .createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES); - - search(type, REFERENCES, scope, this.resultCollector); - - assertSearchResults("src/b297825/Main.java void b297825.Main.main(String[]) [Foo] EXACT_MATCH"); - } finally { - deleteProject("P"); - } - } - /** - * @bug 342393: Anonymous class' occurrence count is incorrect when two methods in a class have the same name. - * @test Search for Enumerators with anonymous types - * - * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=342393" - */ - public void testBug342393() throws CoreException { - try { - IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "bin", "1.5"); - String content = "package b342393;\n" + "class Generic {\n" - + "enum A {\n" + "ONE {\n" + "A getSquare() {\n" - + "return ONE;\n" + "}\n" + "},\n" + "TWO {\n" - + "A getSquare() {\n" + "return TWO;\n" + "}\n" + "};\n" - + "abstract A getSquare();\n" + "}\n" + "}"; - createFolder("/P/b342393"); - createFile("/P/b342393/Generic.java", content); - IJavaSearchScope scope = SearchEngine. createJavaSearchScope( - new IJavaElement[] { project }, IJavaSearchScope.SOURCES); - search("getSquare", METHOD, DECLARATIONS, EXACT_RULE, scope, this.resultCollector); - assertSearchResults("b342393/Generic.java A b342393.Generic$A.ONE:#1.getSquare() [getSquare] EXACT_MATCH\n" + - "b342393/Generic.java A b342393.Generic$A.TWO:#1.getSquare() [getSquare] EXACT_MATCH\n" + - "b342393/Generic.java A b342393.Generic$A.getSquare() [getSquare] EXACT_MATCH"); - } finally { - deleteProject("P"); - } - } - - /** - * @bug 376673: DBCS4.2 Can not rename the class names when DBCS (Surrogate e.g. U+20B9F) is in it - * @test Search for DBCS type should report the match - * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=376673" - */ - public void testBug376673a() throws CoreException { - try { - if ("macosx".equals(System.getProperty("osgi.os"))) { - System.out.println("testBug376673* may fail on macosx"); - return; - } - IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL17_LIB"}, "bin", "1.7"); - String content = "package pkg;\n" + - "class \uD842\uDF9F1 {}\n"; - createFolder("/P/pkg"); - try { - IFile file = createFile("/P/pkg/\uD842\uDF9F1.java", content, "UTF-8"); - file.setCharset("UTF-8", null); - } catch (UnsupportedEncodingException e) { - System.out.println("unsupported encoding"); - } - waitUntilIndexesReady(); - IJavaSearchScope scope = SearchEngine. createJavaSearchScope( - new IJavaElement[] { project }, IJavaSearchScope.SOURCES); - search("\uD842\uDF9F1", TYPE, DECLARATIONS, EXACT_RULE, scope, this.resultCollector); - assertSearchResults("pkg/\uD842\uDF9F1.java pkg.\uD842\uDF9F1 [\uD842\uDF9F1] EXACT_MATCH"); - } finally { - deleteProject("P"); - } - } - // Search for DBCS method should report the match - public void testBug376673b() throws CoreException { - try { - if ("macosx".equals(System.getProperty("osgi.os"))) { - return; - } - IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL17_LIB"}, "bin", "1.7"); - String content = "package pkg;\n" + - "class \uD842\uDF9F1 {" + - " public void \uD842\uDF9Fm() {}\n" + - "}\n"; - createFolder("/P/pkg"); - try { - IFile file = createFile("/P/pkg/\uD842\uDF9F1.java", content, "UTF-8"); - file.setCharset("UTF-8", null); - } catch (UnsupportedEncodingException e) { - System.out.println("unsupported encoding"); - } - waitUntilIndexesReady(); - IJavaSearchScope scope = SearchEngine. createJavaSearchScope( - new IJavaElement[] { project }, IJavaSearchScope.SOURCES); - search("\uD842\uDF9Fm", METHOD, DECLARATIONS, EXACT_RULE, scope, this.resultCollector); - assertSearchResults("pkg/\uD842\uDF9F1.java void pkg.\uD842\uDF9F1.\uD842\uDF9Fm() [\uD842\uDF9Fm] EXACT_MATCH"); - } finally { - deleteProject("P"); - } - } - // Search for DBCS constructor should report the match - public void testBug376673c() throws CoreException { - try { - if ("macosx".equals(System.getProperty("osgi.os"))) { - return; - } - IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL17_LIB"}, "bin", "1.7"); - String content = "package pkg;\n" + - "class \uD842\uDF9F1 {" + - " public \uD842\uDF9F1() {}\n" + - "}\n"; - createFolder("/P/pkg"); - try { - IFile file = createFile("/P/pkg/\uD842\uDF9F1.java", content, "UTF-8"); - file.setCharset("UTF-8", null); - } catch (UnsupportedEncodingException e) { - System.out.println("unsupported encoding"); - } - waitUntilIndexesReady(); - IJavaSearchScope scope = SearchEngine. createJavaSearchScope( - new IJavaElement[] { project }, IJavaSearchScope.SOURCES); - search("\uD842\uDF9F1", CONSTRUCTOR, DECLARATIONS, EXACT_RULE, scope, this.resultCollector); - assertSearchResults("pkg/\uD842\uDF9F1.java pkg.\uD842\uDF9F1() [\uD842\uDF9F1] EXACT_MATCH"); - } finally { - deleteProject("P"); - } - } - // Search for DBCS field should report the match - public void testBug376673d() throws CoreException { - try { - if ("macosx".equals(System.getProperty("osgi.os"))) { - return; - } - IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL17_LIB"}, "bin", "1.7"); - String content = "package pkg;\n" + - "class \uD842\uDF9F1 {" + - " public int \uD842\uDF9Ff;\n" + - "}\n"; - createFolder("/P/pkg"); - try { - IFile file = createFile("/P/pkg/\uD842\uDF9F1.java", content, "UTF-8"); - file.setCharset("UTF-8", null); - } catch (UnsupportedEncodingException e) { - System.out.println("unsupported encoding"); - } - waitUntilIndexesReady(); - IJavaSearchScope scope = SearchEngine. createJavaSearchScope( - new IJavaElement[] { project }, IJavaSearchScope.SOURCES); - search("\uD842\uDF9Ff", FIELD, DECLARATIONS, EXACT_RULE, scope, this.resultCollector); - assertSearchResults("pkg/\uD842\uDF9F1.java pkg.\uD842\uDF9F1.\uD842\uDF9Ff [\uD842\uDF9Ff] EXACT_MATCH"); - } finally { - deleteProject("P"); - } - } - // Search for DBCS package name from a jar also should report the match - public void testBug376673e() throws CoreException, IOException { - try { - if ("macosx".equals(System.getProperty("osgi.os"))) { - return; - } - String os = Platform.getOS(); - if (!Platform.OS_WIN32.equals(os)) { - // on Windows we have Windows-1252 as default, *nix should use UTF-8 - assertUTF8Encoding(); - } - IJavaProject p = createJavaProject("P", new String[] {}, new String[] { "/P/lib376673.jar", "JCL17_LIB" }, "", "1.7"); - IPath jarPath = p.getProject().getLocation().append("lib376673.jar"); - - org.eclipse.jdt.core.tests.util.Util.createJar( - new String[] { - "p\uD842\uDF9F/i\uD842\uDF9F/Test.java", - "package p\uD842\uDF9F.i\uD842\uDF9F;\n" + - "public class Test{}\n" }, - jarPath.toOSString(), - "1.7"); - refresh(p); - waitForAutoBuild(); - waitUntilIndexesReady(); - int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES; - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, mask); - search("Test", TYPE, DECLARATIONS, scope, this.resultCollector); - - try { - if (this.resultCollector.count == 0) { - System.out.println("Test " + getName() + " about to fail, listing extra debug info"); - System.out.println("LANG env variable: " + System.getenv("LANG")); - System.out.println("Listing markers of test project"); - IMarker[] markers = p.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE); - for (IMarker marker : markers) { - System.out.println(marker.getAttribute(IMarker.SEVERITY) + ":" + marker.getAttribute(IMarker.MESSAGE)); - } - System.out.println("Resolved classpath entries for test project:"); - for (IClasspathEntry e : p.getResolvedClasspath(false)) { - System.out.println(e); - } - System.out.println("All classpath entries for test project:"); - for (IClasspathEntry e : p.getResolvedClasspath(true)) { - System.out.println(e); - } - printJavaElements(p, System.out); - String jarFilePath = jarPath.toOSString(); - printZipContents(new File(jarFilePath), System.out); - } - } catch (Throwable t) { - System.out.println("Exception occurred while printing extra infos for test " + getName()); - t.printStackTrace(System.out); - } - - assertSearchResults("lib376673.jar p\uD842\uDF9F.i\uD842\uDF9F.Test [No source] EXACT_MATCH"); - } finally { - deleteProject("P"); - } - } - /** - * @bug 357547: [search] Search for method references is returning methods as overridden even if the superclass's method is only package-visible - * @test Search for a non-overridden method because of package visibility should not be found - * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=357547" - */ - public void testBug357547a() throws CoreException { - IJavaProject project = null; - try - { - project = createJavaProject("P"); - createFolder("/P/p1"); - createFile("/P/p1/B.java", - "package p1;\n" + - "import p2.*;\n" + - "public class B extends A {\n" + - "long k(){\n" + - "return 0;\n" + - "}\n" + - "}\n"); - createFolder("/P/p2"); - createFile("/P/p2/A.java", - "package p2;\n" + - "public class A {\n" + - "long k(){\n" + - "return 0;\n" + - "}\n" + - "public long m(){\n"+ - "return new A().k();\n" + - "}\n"+ - "}\n"); - IType type = getCompilationUnit("/P/p1/B.java").getType("B"); - IMethod method = type.getMethod("k", new String[]{}); - search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults("Should not get any results", "", this.resultCollector); - } finally { - deleteProject(project); - } - } - - // search for the method name should also not return matches if not-overridden because of package-visible - public void testBug357547b() throws CoreException { - IJavaProject project = null; - try - { - project = createJavaProject("P"); - createFolder("/P/p1"); - createFile("/P/p1/B.java", - "package p1;\n" + - "import p2.*;\n" + - "public class B extends A {\n" + - "long k(){\n" + - "return 0;\n" + - "}\n" + - "}\n"); - createFolder("/P/p2"); - createFile("/P/p2/A.java", - "package p2;\n" + - "public class A {\n" + - "long k(){\n" + - "return 0;\n" + - "}\n" + - "public long m(){\n"+ - "return new A().k();\n" + - "}\n"+ - "}\n"); - waitUntilIndexesReady(); - // search - SearchPattern pattern = SearchPattern.createPattern("p*.B.k()", METHOD, REFERENCES , 0 ); - search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }), this.resultCollector); - assertSearchResults("Should not get any results", "", this.resultCollector); - } finally { - deleteProject(project); - } - } - - // search for the method name should return the match if same package - public void testBug357547c() throws CoreException { - IJavaProject project = null; - try - { - project = createJavaProject("P"); - createFolder("/P/p2"); - createFile("/P/p2/B.java", - "package p2;\n" + - "public class B extends A {\n" + - "long k(){\n" + - "return 0;\n" + - "}\n" + - "}\n"); - createFile("/P/p2/A.java", - "package p2;\n" + - "public class A {\n" + - "long k(){\n" + - "return 0;\n" + - "}\n" + - "public long m(){\n"+ - "return new A().k();\n" + - "}\n"+ - "}\n"); - waitUntilIndexesReady(); - // search - SearchPattern pattern = SearchPattern.createPattern("B.k()", METHOD, REFERENCES, EXACT_RULE); - search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }), this.resultCollector); - assertSearchResults("Wrong results", "p2/A.java long p2.A.m() [k()] EXACT_MATCH", this.resultCollector); - } finally { - deleteProject(project); - } - } - public void testBug357547d() throws CoreException { - IJavaProject project = null; - try - { - project = createJavaProject("P"); - createFolder("/P/p1"); - createFile("/P/p1/B.java", - "package p1;\n" + - "import p2.*;\n" + - "public class B extends A {\n" + - "long k(){\n" + - "return 0;\n" + - "}\n" + - "}\n"); - createFolder("/P/p2"); - createFile("/P/p2/A.java", - "package p2;\n" + - "public class A{ \n" + - "long k(){\n" + - "return 0;\n" + - "}\n" + - "public long m(){\n"+ - "return new A().k();\n" + - "}\n"+ - "}\n"); - createFile("/P/p2/B.java", - "package p2;\n" + - "public class B {\n" + - "}\n"); - waitUntilIndexesReady(); - // search - SearchPattern pattern = SearchPattern.createPattern("B.k()", METHOD, REFERENCES, EXACT_RULE); - search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }), this.resultCollector); - assertSearchResults("Should not get any results", "", this.resultCollector); - } finally { - deleteProject(project); - } - } - // search for the method name should also not return matches if not-overridden because of package-visible - // even if they are in jars - public void testBug357547e() throws CoreException, IOException { - IJavaProject project = null; - try - { - project = createJavaProject("P", new String[] {""}, new String[] { "/P/lib357547.jar", "JCL15_LIB" }, "", "1.5"); - org.eclipse.jdt.core.tests.util.Util.createJar(new String[] { - "p2/A.java", - "package p2;\n" + - "public class A{}\n" }, - project.getProject().getLocation().append("libStuff.jar").toOSString(), "1.5"); - - org.eclipse.jdt.core.tests.util.Util.createJar( - new String[] { - "p1/B.java", - "package p1;\n"+ - "import p2.*;\n"+ - "public class B extends A {\n" + - "long k(){\n" + - "return 0;\n" + - "}\n" + - "}\n"}, - null, - project.getProject().getLocation().append("lib357547.jar").toOSString(), - new String[] { project.getProject().getLocation().append("libStuff.jar").toOSString() }, - "1.5"); - refresh(project); - createFolder("/P/p2"); - createFile("/P/p2/A.java", - "package p2;\n" + - "public class A {\n" + - "long k(){\n" + - "return 0;\n" + - "}\n" + - "public long m(){\n"+ - "return new A().k();\n" + - "}\n"+ - "}\n"); - waitUntilIndexesReady(); - // search - SearchPattern pattern = SearchPattern.createPattern("B.k()", METHOD, REFERENCES, EXACT_RULE); - search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES), this.resultCollector); - assertSearchResults("Wrong results", "", this.resultCollector); - } finally { - deleteProject(project); - } - } - // search for the method name should also not return matches if not-overridden because of package-visible - // even if they are in jars - public void testBug357547f() throws CoreException, IOException { - IJavaProject project = null; - try - { - project = createJavaProject("P", new String[] {""}, new String[] { "/P/lib357547.jar", "JCL15_LIB" }, "", "1.5"); - org.eclipse.jdt.core.tests.util.Util.createJar(new String[] { - "p2/A.java", - "package p2;\n" + - "public class A{}\n" }, - project.getProject().getLocation().append("libStuff.jar").toOSString(), "1.5"); - - org.eclipse.jdt.core.tests.util.Util.createJar( - new String[] { - "p2/B.java", - "package p2;\n" + - "import p2.*;\n" + - "public class B extends A {\n" + - "long k(){\n" + - "return 0;\n" + - "}\n" + - "}\n"}, - null, - project.getProject().getLocation().append("lib357547.jar").toOSString(), - new String[] { project.getProject().getLocation().append("libStuff.jar").toOSString() }, - "1.5"); - refresh(project); - createFolder("/P/p2"); - createFile("/P/p2/A.java", - "package p2;\n" + - "public class A {\n" + - "long k(){\n" + - "return 0;\n" + - "}\n" + - "public long m(){\n"+ - "return new A().k();\n" + - "}\n"+ - "}\n"); - waitUntilIndexesReady(); - // search - SearchPattern pattern = SearchPattern.createPattern("B.k()", METHOD, REFERENCES, EXACT_RULE); - search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES), this.resultCollector); - assertSearchResults("Wrong results", "p2/A.java long p2.A.m() [k()] EXACT_MATCH", this.resultCollector); - } finally { - deleteProject(project); - } - } - // search for declarations also should take care of default - public void testBug357547g() throws CoreException { - IJavaProject project = null; - try - { - project = createJavaProject("P"); - createFolder("/P/p1"); - createFile("/P/p1/B.java", - "package p1;\n" + - "import p2.*;\n" + - "public class B extends A {\n" + - "long k(int a){\n" + - "return 0;\n" + - "}\n" + - "}\n"); - createFile("/P/p1/C.java", - "package p1;\n" + - "public class C extends B {\n" + - "long k(int a){\n" + - "return 0;\n" + - "}\n" + - "}\n"); - createFolder("/P/p2"); - createFile("/P/p2/A.java", - "package p2;\n" + - "public class A{ \n" + - "long k(int a){\n" + - "return 0;\n" + - "}\n" + - "public long m(){\n"+ - "return new A().k(0);\n" + - "}\n"+ - "}\n"); - createFile("/P/p2/B.java", - "package p2;\n" + - "public class B {\n" + - "}\n"); - waitUntilIndexesReady(); - // search - SearchPattern pattern = SearchPattern.createPattern("A.k(int)", METHOD, DECLARATIONS, EXACT_RULE); - search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }), this.resultCollector); - assertSearchResults("Wrong results", "p2/A.java long p2.A.k(int) [k] EXACT_MATCH", this.resultCollector); - } finally { - deleteProject(project); - } - } - public void testBug378390() throws CoreException { - IJavaProject project = null; - try - { - project = createJavaProject("P"); - createFolder("/P/p1"); - createFile("/P/p1/B.java", - "package p1;\n" + - "import p2.*;\n" + - "public class B extends A {\n" + - "long k(){\n" + - "return 0;\n" + - "}\n" + - "}\n"); - createFolder("/P/p2"); - createFile("/P/p2/A.java", - "package p2;\n" + - "public class A {\n" + - "class B extends A {\n" + - "long k(){\n" + - "return 0;\n" + - "}\n" + - "}\n" + - "long k(){\n" + - "return 0;\n" + - "}\n" + - "public long m(){\n"+ - "return new A().k();\n" + - "}\n"+ - "}\n"); - IType type = getCompilationUnit("/P/p2/A.java").getType("A"); - type = type.getTypes()[0]; - IMethod method = type.getMethod("k", new String[]{}); - search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults("Wrong results", "p2/A.java long p2.A.m() [k()] EXACT_MATCH", this.resultCollector); - } finally { - deleteProject(project); - } - } - /** - * @bug 375971: [search] Not finding method references with generics - * @test TODO - * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=375971" - */ - public void testBug375971a() throws CoreException { - try { - createJavaProject("P"); - createFile("/P/InterfaceI.java", - "public interface InterfaceI {\n"+ - " public void addListener();\n"+ - "}\n"); - createFile("/P/ClassA.java", - "public class ClassA implements InterfaceI{\n"+ - " public void addListener() {\n" + - "}\n" + - "}\n"); - createFile("/P/ClassB.java", - "public class ClassB extends ClassA{\n"+ - " public void doSomething() {" + - " addListener();\n"+ - "}\n" + - "}\n"); - waitUntilIndexesReady(); - // search - IType type = getCompilationUnit("/P/InterfaceI.java").getType("InterfaceI"); - IMethod method = type.getMethod("addListener", new String[]{}); - this.resultCollector.showRule(); - search(method, REFERENCES, ERASURE_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults("ClassB.java void ClassB.doSomething() [addListener()] ERASURE_MATCH"); - } finally { - deleteProject("P"); - } - } - public void testBug375971b() throws CoreException { - try { - createJavaProject("P"); - createFile("/P/InterfaceI.java", - "public interface InterfaceI {\n"+ - " public void addListener();\n"+ - "}\n"); - createFile("/P/ClassA.java", - "public class ClassA {\n"+ - " public void addListener() {\n" + - "}\n" + - "}\n"); - createFile("/P/ClassB.java", - "public class ClassB extends ClassA implements InterfaceI{\n"+ - " public void doSomething() {" + - " addListener();\n"+ - "}\n" + - "}\n"); - waitUntilIndexesReady(); - // search - IType type = getCompilationUnit("/P/InterfaceI.java").getType("InterfaceI"); - IMethod method = type.getMethod("addListener", new String[]{}); - this.resultCollector.showRule(); - search(method, REFERENCES, ERASURE_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults("ClassB.java void ClassB.doSomething() [addListener()] ERASURE_MATCH"); - } finally { - deleteProject("P"); - } - } - public void testBug375971c() throws CoreException { - try { - createJavaProject("P"); - createFile("/P/InterfaceI.java", - "public interface InterfaceI {\n"+ - " public void addListener();\n"+ - "}\n"); - createFile("/P/ClassA.java", - "public class ClassA {\n"+ - " public void addListener() {\n" + - "}\n" + - "}\n"); - createFile("/P/ClassB.java", - "public class ClassB extends ClassA implements InterfaceI{\n"+ - " public void doSomething() {" + - " addListener();\n"+ - "}\n" + - "}\n"); - waitUntilIndexesReady(); - // search - IType type = getCompilationUnit("/P/ClassA.java").getType("ClassA"); - IMethod method = type.getMethod("addListener", new String[]{}); - this.resultCollector.showRule(); - search(method, REFERENCES, ERASURE_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults("ClassB.java void ClassB.doSomething() [addListener()] ERASURE_MATCH"); - } finally { - deleteProject("P"); - } - } - public void testBug375971d() throws CoreException { - try { - createJavaProject("P"); - createFile("/P/InterfaceI.java", - "public interface InterfaceI {\n"+ - " public void addListener();\n"+ - "}\n"); - createFile("/P/ClassA.java", - "public class ClassA implements InterfaceI{\n"+ - " public void addListener() {\n" + - "}\n" + - "}\n"); - createFile("/P/ClassB.java", - "public class ClassB {\n"+ - " public void doSomething(ClassA a) {" + - " a.addListener();\n"+ - "}\n" + - "}\n"); - waitUntilIndexesReady(); - // search - IType type = getCompilationUnit("/P/InterfaceI.java").getType("InterfaceI"); - IMethod method = type.getMethod("addListener", new String[]{}); - this.resultCollector.showRule(); - search(method, REFERENCES, ERASURE_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults("ClassB.java void ClassB.doSomething(ClassA) [addListener()] ERASURE_RAW_MATCH"); - } finally { - deleteProject("P"); - } - } - public void testBug375971e() throws CoreException { - try { - createJavaProject("P"); - createFile("/P/InterfaceI.java", - "public interface InterfaceI {\n"+ - " public void addListener();\n"+ - "}\n"); - createFile("/P/ClassA.java", - "public class ClassA implements InterfaceI {\n"+ - " public void addListener() {\n" + - "}\n" + - "}\n"); - createFile("/P/ClassB.java", - "public class ClassB implements InterfaceI {\n"+ - " public void doSomething() {" + - " addListener();\n"+ - "}\n" + - "}\n"); - createFile("/P/ClassC.java", - "public class ClassC extends ClassA {\n"+ - " public void doSomething() {" + - " addListener();\n"+ - "}\n" + - "}\n"); - waitUntilIndexesReady(); - // search - ICompilationUnit unit = getCompilationUnit("/P/ClassB.java"); - IMethod method = selectMethod(unit, "addListener"); - this.resultCollector.showRule(); - search(method, REFERENCES, ERASURE_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults("ClassB.java void ClassB.doSomething() [addListener()] EXACT_MATCH\n" + - "ClassC.java void ClassC.doSomething() [addListener()] ERASURE_MATCH"); - } finally { - deleteProject("P"); - } - } - public void testBug375971f() throws CoreException { - try { - createJavaProject("P"); - createFile("/P/InterfaceI.java", - "public interface InterfaceI {\n"+ - " public void addListener();\n"+ - "}\n"); - createFile("/P/ClassA.java", - "public class ClassA implements InterfaceI{\n"+ - " public void addListener() {\n" + - "}\n" + - "}\n"); - createFile("/P/ClassB.java", - "public class ClassB extends ClassA{\n"+ - " public void doSomething() {" + - " addListener();\n"+ - "}\n" + - "}\n"); - waitUntilIndexesReady(); - // search - IType type = getCompilationUnit("/P/InterfaceI.java").getType("InterfaceI"); - IMethod method = type.getMethod("addListener", new String[]{}); - this.resultCollector.showRule(); - search(method, REFERENCES, ERASURE_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults("ClassB.java void ClassB.doSomething() [addListener()] EXACT_MATCH"); - } finally { - deleteProject("P"); - } - } - public void testBug375971g() throws CoreException { - try { - createJavaProject("P"); - createFile("/P/InterfaceI.java", - "public interface InterfaceI {\n"+ - " public void addListener();\n"+ - "}\n"); - createFile("/P/ClassA.java", - "public class ClassA implements InterfaceI{\n"+ - " public void addListener() {\n" + - "}\n" + - "}\n"); - createFile("/P/ClassB.java", - "public class ClassB extends ClassA{\n"+ - " public void doSomething() {" + - " addListener();\n"+ - "}\n" + - "}\n"); - waitUntilIndexesReady(); - // search - IType type = getCompilationUnit("/P/InterfaceI.java").getType("InterfaceI"); - IMethod method = type.getMethod("addListener", new String[]{}); - this.resultCollector.showRule(); - search(method, REFERENCES, ERASURE_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults("ClassB.java void ClassB.doSomething() [addListener()] EXACT_MATCH"); - } finally { - deleteProject("P"); - } - } - public void testBug375971h() throws CoreException { - try { - createJavaProject("P"); - createFile("/P/InterfaceI.java", - "public interface InterfaceI {\n"+ - " public void addListener();\n"+ - "}\n"); - createFile("/P/ClassA.java", - "public class ClassA implements InterfaceI{\n"+ - " public void addListener() {\n" + - "}\n" + - "}\n"); - createFile("/P/ClassB.java", - "public class ClassB extends ClassA{\n"+ - " public void doSomething(InterfaceI i) {" + - " i.addListener();\n"+ - "}\n" + - "}\n"); - waitUntilIndexesReady(); - // search - IType type = getCompilationUnit("/P/ClassA.java").getType("ClassA"); - IMethod method = type.getMethod("addListener", new String[]{}); - this.resultCollector.showRule(); - search(method, REFERENCES, ERASURE_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults("ClassB.java void ClassB.doSomething(InterfaceI) [addListener()] EXACT_MATCH"); - } finally { - deleteProject("P"); - } - } - public void testBug375971i() throws CoreException { - try { - createJavaProject("P"); - createFile("/P/InterfaceI.java", - "public interface InterfaceI {\n"+ - " public void addListener(K k);\n"+ - "}\n"); - createFile("/P/ClassA.java", - "public class ClassA implements InterfaceI{\n"+ - "public void addListener(K k) {\n" + - "}\n" + - "}\n"); - createFile("/P/ClassB.java", - "public class ClassB extends ClassA{\n"+ - " public void doSomething(K k) {" + - " addListener(k);\n"+ - "}\n" + - "}\n"); - waitUntilIndexesReady(); - // search - IType type = getCompilationUnit("/P/InterfaceI.java").getType("InterfaceI"); - IMethod method = type.getMethods()[0]; - this.resultCollector.showRule(); - search(method, REFERENCES, ERASURE_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults("ClassB.java void ClassB.doSomething(K) [addListener(k)] ERASURE_MATCH"); - } finally { - deleteProject("P"); - } - } - // search for constructor declarations in javadoc - public void testBug381567a() throws CoreException { - try { - IJavaProject p = createJavaProject("P", new String[] { "src" }, - new String[] {"JCL_LIB"}, "bin"); - createFolder("/P/src/b381567"); - createFile("/P/src/b381567/A.java", - "package b381567;\n" + - "/**\n" + - "* {@link B#equals(java.lang.Object)}\n" + - "*/\n" + - "public class A {\n" + - " A() {}\n" + - "}"); - createFile("/P/src/b381567/B.java", - "package b381567;\n" + - "public class B {\n" + - "}"); - waitUntilIndexesReady(); - IJavaSearchScope scope = SearchEngine - .createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES); - SearchPattern pattern = SearchPattern.createPattern("*", CONSTRUCTOR, DECLARATIONS, SearchPattern.R_PATTERN_MATCH); - this.resultCollector.showInsideDoc(); - - search(pattern, scope, this.resultCollector); - - assertSearchResults("src/b381567/A.java b381567.A() [A] EXACT_MATCH OUTSIDE_JAVADOC"); - } finally { - deleteProject("P"); - } - } - // search for all constructor occurrences (declarations and references) in javadoc - public void testBug381567b() throws CoreException { - try { - IJavaProject p = createJavaProject("P", new String[] { "src" }, - new String[] {"JCL_LIB"}, "bin"); - createFolder("/P/src/b381567"); - createFile("/P/src/b381567/A.java", - "package b381567;\n" + - "class A {\n" + - " A(Exception ex) {}\n" + - " class B { \n" + - " /**\n" + - " * Link {@link #A(Exception)} OK\n" + - " */\n" + - " public B(String str) {}\n" + - " }\n" + - "}" - ); - waitUntilIndexesReady(); - IMethod[] methods = getCompilationUnit("/P/src/b381567/A.java") - .getType("A").getMethods(); - assertEquals("Invalid number of methods", 1, methods.length); - assertTrue(methods[0].isConstructor()); - IJavaSearchScope scope = SearchEngine - .createJavaSearchScope(new IJavaElement[] { p }); - this.resultCollector.showInsideDoc(); - - search(methods[0], ALL_OCCURRENCES, scope); - - assertSearchResults("src/b381567/A.java b381567.A(Exception) [A] EXACT_MATCH OUTSIDE_JAVADOC\n" - + "src/b381567/A.java b381567.A$B(String) [A(Exception)] EXACT_MATCH INSIDE_JAVADOC"); - } finally { - deleteProject("P"); - } - } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=382778, Call hierarchy missing valid callers probably because java search marks exact matches as potential - public void testBug382778() throws CoreException { - try { - IJavaProject p = createJavaProject("P", new String[] { "src" }, - new String[] {"JCL_LIB"}, "bin"); - createFolder("/P/src/b382778"); - createFile("/P/src/b382778/Impl2.java", - "package b382778;\n" + - "public class Impl2 implements PublicInterface2 {\n" + - " private final String name;\n" + - " public Impl2(String name) {\n" + - " this.name = name;\n" + - " }\n" + - " public String getName() {\n" + - " return name;\n" + - " }\n" + - "}\n" - ); - createFile("/P/src/b382778/Main.java", - "package b382778;\n" + - "public class Main {\n" + - " public static void main(String[] args) {\n" + - " broken();\n" + - " ok();\n" + - " }\n" + - " private static void broken() {\n" + - " PublicInterface2 impl2 = new Impl2(\"Name Broken\");\n" + - " Static.printIt(impl2.getName());\n" + - " }\n" + - " private static void ok() {\n" + - " PublicInterface2 impl2 = new Impl2(\"Name OK\");\n" + - " String name = impl2.getName();\n" + - " Static.printIt(name);\n" + - " }\n" + - "}\n" - ); - createFile("/P/src/b382778/MainBroken.java", - "package b382778;\n" + - "public class MainBroken {\n" + - " public static void main(String[] args) {\n" + - " PublicInterface2 impl2 = new Impl2(\"Name Broken\");\n" + - " Static.printIt(impl2.getName());\n" + - " }\n" + - "}\n" - ); - createFile("/P/src/b382778/MainOK.java", - "package b382778;\n" + - "public class MainOK {\n" + - " public static void main(String[] args) {\n" + - " PublicInterface2 impl2 = new Impl2(\"Name OK\");\n" + - " String name = impl2.getName();\n" + - " Static.printIt(name);\n" + - " }\n" + - "}\n" - ); - createFile("/P/src/b382778/PublicInterface1.java", - "package b382778;\n" + - "public interface PublicInterface1 extends PackageInterface1Getters {\n" + - "}\n" + - "/* package */interface PackageInterface1Getters {\n" + - "String getName();\n" + - "}" - ); - createFile("/P/src/b382778/PublicInterface2.java", - "package b382778;\n" + - "public interface PublicInterface2 extends PackageInterface2Getters {\n" + - "}\n" + - "/* package */interface PackageInterface2Getters extends PackageInterface1Getters {\n" + - "}\n" - ); - createFile("/P/src/b382778/Static.java", - "package b382778;\n" + - "public class Static {\n" + - "public static void printIt(String it) {\n" + - "System.out.println(it);\n" + - "}\n" + - "}" - ); - waitUntilIndexesReady(); - ICompilationUnit unit = getCompilationUnit("/P/src/b382778/Static.java"); - IMethod method = unit.getType("Static").getMethod("printIt", - new String[] { "QString;" }); - IJavaSearchScope scope = SearchEngine - .createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES); - - search(method, REFERENCES, scope, this.resultCollector); - - assertSearchResults("src/b382778/Main.java void b382778.Main.broken() [printIt(impl2.getName())] EXACT_MATCH\n" - + "src/b382778/Main.java void b382778.Main.ok() [printIt(name)] EXACT_MATCH\n" - + "src/b382778/MainBroken.java void b382778.MainBroken.main(String[]) [printIt(impl2.getName())] EXACT_MATCH\n" - + "src/b382778/MainOK.java void b382778.MainOK.main(String[]) [printIt(name)] EXACT_MATCH"); - } finally { - deleteProject("P"); - } - } - public void testBug383315a() throws CoreException { - try { - IJavaProject p = createJavaProject("P", new String[] {}, new String[] { "JCL15_LIB" }, "", "1.5"); - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES); - - search("java.lang.Object.hashCode()", METHOD, ALL_OCCURRENCES, scope, this.resultCollector); - - assertSearchResults(""); // an NPE was thrown without the fix - } finally { - deleteProject("P"); - } - } - public void testBug383315b() throws CoreException { - try { - IJavaProject p = createJavaProject("P"); - createFolder("/P/pkg"); - createFile("/P/pkg/A.java", - "package pkg;\n"+ - "public class A {\n"+ - " void a() {\n"+ - " }\n"+ - "}"); - createFile("/P/pkg/B.java", - "package pkg;\n"+ - "public class B extends A {\n"+ - " void a() {\n"+ - " }\n"+ - "}"); - createFile("/P/pkg/C.java", - "package pkg;\n"+ - "public class C extends B {\n"+ - " void a() {\n"+ - " }\n"+ - "}"); - createFile("/P/pkg/D.java", - "package pkg;\n"+ - "public class D extends C {\n"+ - " void a() {\n"+ - " }\n"+ - " void d() {\n"+ - " new A().a();\n"+ - " }\n"+ - "}"); - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES); - - search("C.a()", METHOD, REFERENCES, scope, this.resultCollector); - - assertSearchResults("pkg/D.java void pkg.D.d() [a()] EXACT_MATCH"); - } finally { - deleteProject("P"); - } - } - public void testBug395348() throws CoreException { - try { - IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); - createFile("/P/X.java", - "public class X {\n"+ - " static void f() {\n" + - " new Y() {\n"+ - " public int compare(C2 o1) {\n" + - " return 0;\n" + - " }\n" + - " };\n"+ - " }\n" + - "}\n" + - "interface Y {\n" + - " public abstract int compare(T o1);\n" + - "}\n" + - "class C2 {}\n" - ); - IMethod method = selectMethod(getCompilationUnit("/P/X.java"), "compare", 0); - MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(method, DECLARATIONS|IGNORE_DECLARING_TYPE|IGNORE_RETURN_TYPE, EQUIVALENT_RULE|EXACT_RULE); - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.SOURCES); - search(pattern, scope, this.resultCollector); - assertSearchResults("X.java int void X.f():#1.compare(C2) [compare] EXACT_MATCH\n" + - "X.java int Y.compare(T) [compare] EXACT_MATCH"); // an NPE was thrown without the fix - } finally { - deleteProject("P"); - } - } - - public void testBug401272() throws CoreException, IOException { - boolean indexState = isIndexDisabledForTest(); - // the strategy of this test was outlined in https://bugs.eclipse.org/bugs/show_bug.cgi?id=401272#c16 - try { - IJavaProject p = createJavaProject("P", new String[] { "src" }, new String[] { "JCL15_LIB", "/P/libStuff.jar" }, "bin", "1.5"); - - org.eclipse.jdt.core.tests.util.Util.createJar( - new String[] { - // this class must be our possibleMatch #401 - // it must be binary to trigger the ClassFileMatchLocator - // the match must be impossible-due-to-mismatching-type-variables to trigger matchLocator.getMethodBinding(this.pattern); - "p2/A.java", - "package p2;\n" + - "public class A {\n" + - " public int test(E b) { return 1; }\n" + - " void bar() {\n" + - " test(null);\n" + - " }\n" + - "}\n", - // this class contains the method we search for, possibleMatch #402 - // (must be > 401 possibleMatches to trigger environment cleanup) - "p2/B.java", - "package p2;\n" + - "public class B {\n" + - " public int test(T t) {\n" + - " return 0;\n" + - " }\n" + - "}\n" - }, - p.getProject().getLocation().append("libStuff.jar").toOSString(), "1.5"); - refresh(p); - - createFolder("/P/src/pkg"); - - this.indexDisabledForTest = true; - // 400 matches, which populate MatchLocator.unitScope - // all 400 matches are processed in one go of MatchLocator.locateMatches(JavaProject, PossibleMatch[], int, int) - // next round will call nameEnvironment.cleanup() but reuse MatchLocator.unitScope ==> BOOM - for (int i = 0; i < 400; i++) { - createFile("/P/src/pkg/Bug"+i+".java", - "package pkg;\n"+ - "public class Bug"+i+" {\n"+ - " String[] test(p2.B b) {\n" + - " return b.test(\"S\");\n" + - " }\n" + - "}"); - } - waitUntilIndexesReady(); - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, - IJavaSearchScope.SOURCES|IJavaSearchScope.SYSTEM_LIBRARIES|IJavaSearchScope.APPLICATION_LIBRARIES); - - IMethod method = p.findType("p2.B").getMethods()[1]; - search(method, METHOD, ALL_OCCURRENCES, scope, this.resultCollector); - - assertSearchResults("libStuff.jar int p2.B.test(T) [No source] EXACT_MATCH"); // an NPE was thrown without the fix - } finally { - deleteProject("P"); - this.indexDisabledForTest = indexState; - } - } - /** - * @bug 423409: [search] Search shows references to fields as potential matches - * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=423409" - */ - public void testBug423409() throws CoreException, JavaModelException { - try { - createJavaProject("P", new String[] { "src" }, - new String[] {"JCL_LIB"}, "bin"); - createFolder("/P/src/com/test"); - createFile("/P/src/com/test/Test2.java", - "package com.test;\n" + - "\n" + - "class Test2 {\n" + - " public static final FI fi/*here*/ = null; // find references of 'fi' via Ctrl+Shift+G\n" + - " \n" + - " {\n" + - " fun1(fi);\n" + - " }\n" + - " \n" + - " private FI fun1(FI x) {\n" + - " System.out.println(fi);\n" + - " return fi;\n" + - " }\n" + - "}\n" ); - createFile("/P/src/com/test/Test1.java", - "package com.test;\n" + - "\n" + - "class Test1 {\n" + - " public static final FI fi = null;\n" + - "}\n" ); - createFile("/P/src/com/test/T.java", - "package com.test;\n" + - "\n" + - "interface FI {\n" + - " int foo(int x);\n" + - "}\n"); - waitUntilIndexesReady(); - IType type = getCompilationUnit("/P/src/com/test/Test2.java").getType("Test2"); - IJavaElement field = type.getField("fi"); - search(field, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - - assertSearchResults( - "src/com/test/Test2.java com.test.Test2.{} [fi] EXACT_MATCH\n" + - "src/com/test/Test2.java FI com.test.Test2.fun1(FI) [fi] EXACT_MATCH\n" + - "src/com/test/Test2.java FI com.test.Test2.fun1(FI) [fi] EXACT_MATCH"); - } finally { - deleteProject("P"); - } - } - public void testBug381392() throws CoreException { - IJavaProject egit = null; - IJavaProject jgit = null; - try { - jgit = createJavaProject("jgit", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); - createFolder("/jgit/base"); - createFile("/jgit/base/AbstractPlotRenderer.java", - "package base;\n" + - "public abstract class AbstractPlotRenderer {\n"+ - " protected abstract TColor laneColor(TLane myLane);\n"+ - "\n"+ - " @SuppressWarnings(\"unused\")\n"+ - " protected void paintCommit(final PlotCommit commit) {\n"+ - " final TLane myLane = commit.getLane();\n"+ - " final TColor myColor = laneColor(myLane);\n"+ - " }\n"+ - "}\n"); - createFile("/jgit/base/PlotCommit.java", - "package base;\n"+ - "public class PlotCommit {\n"+ - " public L getLane() {\n"+ - " return null;\n"+ - " }\n"+ - "}"); - createFile("/jgit/base/PlotLane.java", - "package base;\n"+ - "public class PlotLane {\n"+ - "}"); - egit = createJavaProject("egit", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); - createFolder("/egit/bug"); - createFile("/egit/bug/SWTPlotLane.java", - "package bug;\n" + - "import base.PlotLane;\n" + - "public class SWTPlotLane extends PlotLane {}"); - createFile("/egit/bug/SWTPlotRenderer.java", - "package bug;\n" + - "import base.AbstractPlotRenderer;\n" + - "class SWTPlotRenderer extends AbstractPlotRenderer {\n" + - " @Override\n" + - " protected Integer laneColor(SWTPlotLane myLane) {\n" + - " return 1;\n" + - " }\n" + - "}"); - addClasspathEntry(egit, JavaCore.newProjectEntry(jgit.getPath())); - - // search - IType type = getCompilationUnit("/egit/bug/SWTPlotRenderer.java").getType("SWTPlotRenderer"); - IMethod method = type.getMethods()[0]; - search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults("base/AbstractPlotRenderer.java void base.AbstractPlotRenderer.paintCommit(PlotCommit) [laneColor(myLane)] EXACT_MATCH"); - } finally { - if (jgit != null) deleteProject(jgit); - if (egit != null) deleteProject(egit); - } - } - public void testBug469965_0001() throws CoreException { - try { - - IJavaProject project = createJavaProject("P", new String[] {"src"}, new String[] { "/P/lib469965.jar", "JCL18_LIB" }, "bin", "1.8"); - String libsource = "package f3;\n" + - "public class X {\n" + - " void foo() {\n" + - " final Y y = new Y();\n" + - " new X() {\n" + - " void goo() { y.bar();}\n" + - " };\n" + - " new X() {\n" + - " void goo() { y.bar();}\n" + - " };\n" + - " }\n" + - " void goo() {\n" + - " final Y y = new Y();\n" + - " new X() {\n" + - " void goo() { y.bar();}\n" + - " };\n" + - " new X() {\n" + - " void goo() { y.bar();}\n" + - " };\n" + - " }\n" + - "}\n" + - "class Y {\n" + - " void bar() {} \n" + - "}\n"; - String jarFileName = "lib469965.jar"; - String srcZipName = "lib469965.src.zip"; - createLibrary(project, jarFileName, srcZipName, new String[] {"f3/X.java",libsource}, new String[0], JavaCore.VERSION_1_5); - IFile srcZip=(IFile) project.getProject().findMember(srcZipName); - IFile jar = (IFile) project.getProject().findMember(jarFileName); - project.getPackageFragmentRoot(jar).attachSource(srcZip.getFullPath(), null, null); - waitUntilIndexesReady(); - - IType type = getClassFile("P", jarFileName, "f3", "Y.class").getType(); - IMethod method = type.getMethods()[1]; - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES); - search(method, REFERENCES, scope); - assertSearchResults( - "lib469965.jar void f3..goo() EXACT_MATCH\n" + - "lib469965.jar void f3..goo() EXACT_MATCH\n" + - "lib469965.jar void f3..goo() EXACT_MATCH\n" + - "lib469965.jar void f3..goo() EXACT_MATCH"); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - finally { - deleteProject("P"); - } - } - public void testBug469965_0002() throws CoreException { - try { - - IJavaProject project = createJavaProject("P", new String[] {"src"}, new String[] { "/P/lib469965.jar", "JCL18_LIB" }, "bin", "1.8"); - String libsource = "package f3;\n" + - "public class X {\n" + - " void foo() {\n" + - " final Y y = new Y();\n" + - " new X() {\n" + - " void goo() { y.bar();}\n" + - " };\n" + - " new X() {\n" + - " void goo() { y.bar();}\n" + - " };\n" + - " }\n" + - " void goo() {\n" + - " final Y y = new Y();\n" + - " new X() {\n" + - " void goo() {\n" + - " new X() {\n" + - " void goo() { y.bar();}\n" + - " };\n" + - " y.bar();\n" + - " }\n" + - " };\n" + - " new X() {\n" + - " void goo() { y.bar();}\n" + - " };\n" + - " }\n" + - "}\n" + - "class Y {\n" + - " void bar() {} \n" + - "}\n"; - String jarFileName = "lib469965.jar"; - String srcZipName = "lib469965.src.zip"; - createLibrary(project, jarFileName, srcZipName, new String[] {"f3/X.java",libsource}, new String[0], JavaCore.VERSION_1_5); - IFile srcZip=(IFile) project.getProject().findMember(srcZipName); - IFile jar = (IFile) project.getProject().findMember(jarFileName); - project.getPackageFragmentRoot(jar).attachSource(srcZip.getFullPath(), null, null); - waitUntilIndexesReady(); - - IType type = getClassFile("P", jarFileName, "f3", "Y.class").getType(); - IMethod method = type.getMethods()[1]; - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES); - search(method, REFERENCES, scope); - assertSearchResults( - "lib469965.jar void f3..goo() EXACT_MATCH\n" + - "lib469965.jar void f3..goo() EXACT_MATCH\n" + - "lib469965.jar void f3..goo() EXACT_MATCH\n" + - "lib469965.jar void f3..goo() EXACT_MATCH\n" + - "lib469965.jar void f3..goo() EXACT_MATCH"); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - finally { - deleteProject("P"); - } - } - - public void testBug473921() throws Exception { - try { - IJavaProject p = this.createJavaProject( - "P", - new String[] {}, - new String[] { "/P/lib473921.jar", "JCL17_LIB" }, - new String[][] {{ "p/*" }, { }}, - new String[][] {{ "**/*" }, { }}, - null/*no project*/, - null/*no inclusion pattern*/, - null/*no exclusion pattern*/, - null/*no exported project*/, - "", - null/*no source outputs*/, - null/*no inclusion pattern*/, - null/*no exclusion pattern*/, - "1.7" - ); - org.eclipse.jdt.core.tests.util.Util.createJar( - new String[] { - "p/Enclosing.java", - "package p;\n" + - "public class Enclosing { enum Nested { A, B; class Matryoshka { } } }\n", - "classified/CEnclosing.java", - "package classified;\n" + - "public class CEnclosing { interface CNested { class CMatryoshka { } } }\n" - }, - p.getProject().getLocation().append("lib473921.jar").toOSString(), - "1.7"); - refresh(p); - - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }); - class Collector extends TypeNameMatchRequestor { - List matches = new ArrayList<>(); - @Override - public void acceptTypeNameMatch(TypeNameMatch match) { - this.matches.add(match); - } - } - Collector collector = new Collector(); - new SearchEngine().searchAllTypeNames( - null, - new char[][] { "Nested".toCharArray(), "Enclosing".toCharArray(), "Matryoshka".toCharArray() }, - scope, - collector, - IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, - null); - assertEquals(3, collector.matches.size()); - assertEquals(IAccessRule.K_ACCESSIBLE, collector.matches.get(0).getAccessibility()); - assertEquals(IAccessRule.K_ACCESSIBLE, collector.matches.get(1).getAccessibility()); // bug 482309 - assertEquals(IAccessRule.K_ACCESSIBLE, collector.matches.get(2).getAccessibility()); // bug 482309 (double-nested type) - - collector = new Collector(); - new SearchEngine().searchAllTypeNames( - null, - new char[][] { "CNested".toCharArray(), "CEnclosing".toCharArray(), "CMatryoshka".toCharArray() }, - scope, - collector, - IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, - null); - assertEquals(3, collector.matches.size()); - assertEquals(IAccessRule.K_NON_ACCESSIBLE, collector.matches.get(0).getAccessibility()); - assertEquals(IAccessRule.K_NON_ACCESSIBLE, collector.matches.get(1).getAccessibility()); // bug 482309 - assertEquals(IAccessRule.K_NON_ACCESSIBLE, collector.matches.get(2).getAccessibility()); // bug 482309 (double-nested type) - } finally { - deleteProject("P"); - } - } - public void testBug478042_0001() throws Exception { - IJavaProject project = null; - try - { - // create the common project and create an interface - project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin","1.5"); - createFolder("P/src/p478042"); - createFile("/P/src/p478042/AllMethodDeclarations01.java", - "package p478042;\n" + - "public class AllMethodDeclarations01 {\n" + - " public void foo01() {}\n" + - " public int foo02(Object o) {return null;}\n" + - " public char foo03(Object o, String s) {return null;}\n" + - " }"); - createFile("/P/src/p478042/AllMethodDeclarations01b.java", - "package p478042;\n" + - "public class AllMethodDeclarations01b {\n" + - " public Integer fooInt() {return null;}\n" + - " }"); - MethodDeclarationsCollector requestor = new MethodDeclarationsCollector(); - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.SOURCES); - searchAllMethodNames("foo", SearchPattern.R_PREFIX_MATCH, scope, requestor); - assertSearchResults( - "/P/src/p478042/AllMethodDeclarations01.java char p478042.AllMethodDeclarations01.foo03(Object o,String s)\n" + - "/P/src/p478042/AllMethodDeclarations01.java int p478042.AllMethodDeclarations01.foo02(Object o)\n" + - "/P/src/p478042/AllMethodDeclarations01.java void p478042.AllMethodDeclarations01.foo01()\n" + - "/P/src/p478042/AllMethodDeclarations01b.java Integer p478042.AllMethodDeclarations01b.fooInt()", - requestor - ); - } finally { - deleteProject(project); - } - } - public void testBug478042_0002() throws Exception { - IJavaProject project = null; - try - { - // create the common project and create an interface - project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin","1.5"); - createFolder("P/src/p478042"); - createFile("/P/src/p478042/AllMethodDeclarations01.java", - "package p478042;\n" + - "public class AllMethodDeclarations01 {\n" + - " public void foo01() {}\n" + - " public int foo02(Object o) {return null;}\n" + - " public char foo03(Object o, String s) {return null;}\n" + - " }"); - createFile("/P/src/p478042/AllMethodDeclarations01b.java", - "package p478042;\n" + - "public class AllMethodDeclarations01b {\n" + - " public Integer fooInt() {return null;}\n" + - " }"); - MethodDeclarationsCollector requestor = new MethodDeclarationsCollector(); - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.SOURCES); - searchAllMethodNames("foo", SearchPattern.R_PREFIX_MATCH, scope, requestor); - assertSearchResults( - "/P/src/p478042/AllMethodDeclarations01.java char p478042.AllMethodDeclarations01.foo03(Object o,String s)\n" + - "/P/src/p478042/AllMethodDeclarations01.java int p478042.AllMethodDeclarations01.foo02(Object o)\n" + - "/P/src/p478042/AllMethodDeclarations01.java void p478042.AllMethodDeclarations01.foo01()\n" + - "/P/src/p478042/AllMethodDeclarations01b.java Integer p478042.AllMethodDeclarations01b.fooInt()", - requestor - ); - } finally { - deleteProject(project); - } - } - public void testBug478042_0003() throws Exception { - IJavaProject project = null; - try { - project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin","1.5"); - createFolder("P/src/p478042"); - createFile("/P/src/p478042/AllMethodDeclarations01.java", - "package p478042;\n" + - "public class AllMethodDeclarations01 {\n" + - " public void foo() {}\n" + - " public void foo01() {}\n" + - " public int foo02(Object o) {return null;}\n" + - " public char foo03(Object o, String s) {return null;}\n" + - " }"); - createFile("/P/src/p478042/AllMethodDeclarations01b.java", - "package p478042;\n" + - "public class AllMethodDeclarations01b {\n" + - " public Integer fooInt() {return null;}\n" + - " }"); - class Collector extends MethodNameMatchRequestor { - List matches = new ArrayList<>(); - @Override - public void acceptMethodNameMatch(MethodNameMatch match) { - this.matches.add(match); - } - } - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.SOURCES); - Collector collector = new Collector(); - new SearchEngine().searchAllMethodNames( - null, SearchPattern.R_EXACT_MATCH, - null, SearchPattern.R_EXACT_MATCH, - "AllMethodDeclarations01".toCharArray(), SearchPattern.R_EXACT_MATCH, - "foo".toCharArray(), SearchPattern.R_PREFIX_MATCH, - scope, collector, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); - assertEquals(4, collector.matches.size()); - } finally { - deleteProject("P"); - } - } - public void testBug478042_0004() throws Exception { - IJavaProject project = null; - try - { - // create the common project and create an interface - project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin","1.5"); - createFolder("P/src/p478042"); - createFile("/P/src/p478042/AllMethodDeclarations01.java", - "package p478042;\n" + - "class Y {}\n" + - "class X {}\n" + - "public class AllMethodDeclarations01 {\n" + - " public Y foo01(Y t) {}\n" + - " public int foo02(Object o) {return null;}\n" + - " public char foo03(Object o, String s) {return null;}\n" + - "}"); - createFile("/P/src/p478042/AllMethodDeclarations01b.java", - "package p478042;\n" + - "public class AllMethodDeclarations01b {\n" + - " public Integer fooInt() {return null;}\n" + - "}"); - MethodDeclarationsCollector requestor = new MethodDeclarationsCollector(); - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.SOURCES); - searchAllMethodNames("foo", SearchPattern.R_PREFIX_MATCH, scope, requestor); - assertSearchResults( - "/P/src/p478042/AllMethodDeclarations01.java Y p478042.AllMethodDeclarations01.foo01(Y t)\n" + - "/P/src/p478042/AllMethodDeclarations01.java char p478042.AllMethodDeclarations01.foo03(Object o,String s)\n" + - "/P/src/p478042/AllMethodDeclarations01.java int p478042.AllMethodDeclarations01.foo02(Object o)\n" + - "/P/src/p478042/AllMethodDeclarations01b.java Integer p478042.AllMethodDeclarations01b.fooInt()", - requestor - ); - } finally { - deleteProject(project); - } - } - public void testBug478042_005() throws Exception { - try { - IJavaProject p = createJavaProject("P", new String[] {}, new String[] { "/P/lib478042.jar", "JCL15_LIB" }, "", "1.5"); - createJar(new String[] { - "p478042/AllMethodDeclarations02.java", - "package p478042;\n" + - "class X {}\n" + - "class Y{}\n" + - "public class AllMethodDeclarations02 {\n" + - " public Y foo01(Y t) { return null;}\n" + - " public int foo02(Object o) {return 0;}\n" + - " public char foo03(Object o, String s) {return '0';}\n" + - "}", - "p478042/AllMethodDeclarations02b.java", - "package p478042;\n" + - "class AllMethodDeclarations02b {\n" + - " public void fooInt() {}\n" + - "}" - }, p.getProject().getLocation().append("lib478042.jar").toOSString(), - new String[] { p.getProject().getLocation().append("lib478042.jar").toOSString() }, - "1.5"); - refresh(p); - - MethodDeclarationsCollector requestor = new MethodDeclarationsCollector(); - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES|IJavaSearchScope.APPLICATION_LIBRARIES); - searchAllMethodNames("foo", SearchPattern.R_PREFIX_MATCH, scope, requestor); - assertSearchResults( - "/P/lib478042.jar|p478042/AllMethodDeclarations02.class char p478042.AllMethodDeclarations02.foo03(java.lang.Object o,java.lang.String s)\n" + - "/P/lib478042.jar|p478042/AllMethodDeclarations02.class int p478042.AllMethodDeclarations02.foo02(java.lang.Object o)\n" + - "/P/lib478042.jar|p478042/AllMethodDeclarations02.class p478042.Y p478042.AllMethodDeclarations02.foo01(p478042.Y t)\n" + - "/P/lib478042.jar|p478042/AllMethodDeclarations02b.class void p478042.AllMethodDeclarations02b.fooInt()", - requestor - ); - } finally { - deleteProject("P"); - } - } - public void testBug478042_006() throws Exception { - try { - IJavaProject p = createJavaProject("P", new String[] {}, new String[] { "/P/lib478042.jar", "JCL15_LIB" }, "", "1.5"); - createJar(new String[] { - "p478042/AllMethodDeclarations01.java", - "package p478042;\n" + - "public class AllMethodDeclarations01 {\n" + - " public class Nested {\n" + - " public class Inner {\n" + - " public void foo01() {}\n" + - " public int foo02(Object o) {return 0;}\n" + - " public char foo03(Object o, String s) {return '0';}\n" + - " }\n" + - " }\n" + - "}\n" - }, p.getProject().getLocation().append("lib478042.jar").toOSString(), - new String[] { p.getProject().getLocation().append("lib478042.jar").toOSString() }, - "1.5"); - refresh(p); - - MethodDeclarationsCollector requestor = new MethodDeclarationsCollector(); - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES|IJavaSearchScope.APPLICATION_LIBRARIES); - searchAllMethodNames("foo", SearchPattern.R_PREFIX_MATCH, scope, requestor); - assertSearchResults( - "/P/lib478042.jar|p478042/AllMethodDeclarations01$Nested$Inner.class char p478042.Inner.foo03(java.lang.Object o,java.lang.String s)\n" + - "/P/lib478042.jar|p478042/AllMethodDeclarations01$Nested$Inner.class int p478042.Inner.foo02(java.lang.Object o)\n" + - "/P/lib478042.jar|p478042/AllMethodDeclarations01$Nested$Inner.class void p478042.Inner.foo01()", - requestor - ); - } finally { - deleteProject("P"); - } - } - public void testBug478042_007() throws Exception { - try { - IJavaProject p = createJavaProject("P", new String[] {}, new String[] { "/P/lib478042.jar", "JCL15_LIB" }, "", "1.5"); - createJar(new String[] { - "p478042/AllMethodDeclarations01.java", - "package p478042;\n" + - "public class AllMethodDeclarations01 {\n" + - " public class Nested {\n" + - " public class Inner {\n" + - " public void foo01() {}\n" + - " public int foo02(Object o) {return 0;}\n" + - " public char foo03(Object o, String s) {return '0';}\n" + - " }\n" + - " }\n" + - "}\n" - }, p.getProject().getLocation().append("lib478042.jar").toOSString(), - new String[] { p.getProject().getLocation().append("lib478042.jar").toOSString() }, - "1.5"); - refresh(p); - - MethodDeclarationsCollector requestor = new MethodDeclarationsCollector(); - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES|IJavaSearchScope.APPLICATION_LIBRARIES); - searchAllMethodNames( - "Inner", SearchPattern.R_EXACT_MATCH, - "foo", SearchPattern.R_PREFIX_MATCH, scope, requestor); - assertSearchResults( - "/P/lib478042.jar|p478042/AllMethodDeclarations01$Nested$Inner.class char p478042.Inner.foo03(java.lang.Object o,java.lang.String s)\n" + - "/P/lib478042.jar|p478042/AllMethodDeclarations01$Nested$Inner.class int p478042.Inner.foo02(java.lang.Object o)\n" + - "/P/lib478042.jar|p478042/AllMethodDeclarations01$Nested$Inner.class void p478042.Inner.foo01()", - requestor - ); - } finally { - deleteProject("P"); - } - } - public void testBug478042_008() throws Exception { - IJavaProject project = null; - try - { - // create the common project and create an interface - project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin","1.5"); - createFolder("P/src/p478042"); - createFile("/P/src/p478042/AllMethodDeclarations01.java", - "package p478042;\n" + - "public class AllMethodDeclarations01 {\n" + - " public class Nested {\n" + - " public class Inner {\n" + - " public void foo01() {}\n" + - " public int foo02(Object o) {return 0;}\n" + - " public char foo03(Object o, String s) {return '0';}\n" + - " }\n" + - " }\n" + - "}"); - MethodDeclarationsCollector requestor = new MethodDeclarationsCollector(); - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.SOURCES); - searchAllMethodNames("foo", SearchPattern.R_PREFIX_MATCH, scope, requestor); - assertSearchResults( - "/P/src/p478042/AllMethodDeclarations01.java char p478042.AllMethodDeclarations01.Nested.Inner.foo03(Object o,String s)\n" + - "/P/src/p478042/AllMethodDeclarations01.java int p478042.AllMethodDeclarations01.Nested.Inner.foo02(Object o)\n" + - "/P/src/p478042/AllMethodDeclarations01.java void p478042.AllMethodDeclarations01.Nested.Inner.foo01()", - requestor - ); - } catch(Exception e) { - e.printStackTrace(); - } finally { - deleteProject(project); - } - } - public void testBug483303_001() throws Exception { - IJavaProject project = null; - try { - project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin","1.5"); - createFolder("P/src/p478042"); - createFile("/P/src/p478042/AllMethodDeclarations01.java", - "package p478042;\n" + - "public class AllMethodDeclarations01 {\n" + - " public void m1(int i) {}\n" + - " public void foo01() {}\n" + - " public int foo02(Object o) {return null;}\n" + - " public char foo03(Object o, String s) {return null;}\n" + - " }"); - createFile("/P/src/p478042/AllMethodDeclarations01b.java", - "package p478042;\n" + - "public class AllMethodDeclarations01b {\n" + - " public Integer fooInt() {return null;}\n" + - " }"); - class Collector extends MethodNameMatchRequestor { - List matches = new ArrayList<>(); - @Override - public void acceptMethodNameMatch(MethodNameMatch match) { - this.matches.add(match); - } - } - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.SOURCES); - Collector collector = new Collector(); - new SearchEngine().searchAllMethodNames( - null, SearchPattern.R_EXACT_MATCH, - null, SearchPattern.R_EXACT_MATCH, - "AllMethodDeclarations01".toCharArray(), SearchPattern.R_EXACT_MATCH, - "m1".toCharArray(), SearchPattern.R_PREFIX_MATCH, - scope, collector, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); - assertEquals(1, collector.matches.size()); - IMethod method = collector.matches.get(0).getMethod(); - assertTrue(method.exists()); - } finally { - deleteProject("P"); - } - } - public void testBug483650_0001() throws Exception { - IJavaProject project = null; - try - { - // create the common project and create an interface - project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin","1.5"); - createFolder("P/src/p478042"); - createFile("/P/src/p478042/AllMethodDeclarations01.java", - "package p478042;\n" + - "public class AllMethodDeclarations01 {\n" + - " public void foo01() {}\n" + - " public int foo02(Object o) {return null;}\n" + - " public char foo03(Object o, String s) {return null;}\n" + - " }"); - createFile("/P/src/p478042/AllMethodDeclarations01b.java", - "package p478042;\n" + - "public class AllMethodDeclarations01b {\n" + - " public Integer fooInt() {return null;}\n" + - " }"); - MethodNameMatchCollector collector = new MethodNameMatchCollector() { - @Override - public String toString() { - return toFullyQualifiedNamesString(); - } - }; - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.SOURCES); - searchAllMethodNames("*", SearchPattern.R_PATTERN_MATCH, "foo", SearchPattern.R_PREFIX_MATCH, scope, collector); - assertSearchResults( - "/P/src/p478042/AllMethodDeclarations01.java void p478042.AllMethodDeclarations01.foo01()\n" + - "/P/src/p478042/AllMethodDeclarations01.java char p478042.AllMethodDeclarations01.foo03(Object o,String s)\n" + - "/P/src/p478042/AllMethodDeclarations01.java int p478042.AllMethodDeclarations01.foo02(Object o)\n" + - "/P/src/p478042/AllMethodDeclarations01b.java Integer p478042.AllMethodDeclarations01b.fooInt()", - collector - ); - } finally { - deleteProject(project); - } - } - public void testBug483650_0002() throws Exception { - IJavaProject project = null; - try - { - // create the common project and create an interface - project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin","1.5"); - createFolder("P/src/p478042"); - createFile("/P/src/p478042/AllMethodDeclarations01.java", - "package p478042;\n" + - "public class AllMethodDeclarations01 {\n" + - " public void foo01() {}\n" + - " public int foo02(Object o) {return null;}\n" + - " public char foo03(Object o, String s) {return null;}\n" + - " }"); - createFile("/P/src/p478042/AllMethodDeclarations01b.java", - "package p478042;\n" + - "public class AllMethodDeclarations01b {\n" + - " public Integer fooInt() {return null;}\n" + - " }"); - MethodNameMatchCollector collector = new MethodNameMatchCollector() { - @Override - public String toString() { - return toFullyQualifiedNamesString(); - } - }; - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.SOURCES); - searchAllMethodNames("*", SearchPattern.R_PATTERN_MATCH, "foo", SearchPattern.R_PREFIX_MATCH, scope, collector); - assertSearchResults( - "/P/src/p478042/AllMethodDeclarations01.java void p478042.AllMethodDeclarations01.foo01()\n" + - "/P/src/p478042/AllMethodDeclarations01.java char p478042.AllMethodDeclarations01.foo03(Object o,String s)\n" + - "/P/src/p478042/AllMethodDeclarations01.java int p478042.AllMethodDeclarations01.foo02(Object o)\n" + - "/P/src/p478042/AllMethodDeclarations01b.java Integer p478042.AllMethodDeclarations01b.fooInt()", - collector - ); - } finally { - deleteProject(project); - } - } - public void testBug483650_0003() throws Exception { - IJavaProject project = null; - try { - project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin","1.5"); - createFolder("P/src/p478042"); - createFile("/P/src/p478042/AllMethodDeclarations01.java", - "package p478042;\n" + - "public class AllMethodDeclarations01 {\n" + - " public void foo() {}\n" + - " public void foo01() {}\n" + - " public int foo02(Object o) {return null;}\n" + - " public char foo03(Object o, String s) {return null;}\n" + - " }"); - createFile("/P/src/p478042/AllMethodDeclarations01b.java", - "package p478042;\n" + - "public class AllMethodDeclarations01b {\n" + - " public Integer fooInt() {return null;}\n" + - " }"); - class Collector extends MethodNameMatchRequestor { - List matches = new ArrayList<>(); - @Override - public void acceptMethodNameMatch(MethodNameMatch match) { - this.matches.add(match); - } - } - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.SOURCES); - Collector collector = new Collector(); - new SearchEngine().searchAllMethodNames( - "*.AllMethodDeclarations01".toCharArray(), SearchPattern.R_PATTERN_MATCH, - "foo".toCharArray(), SearchPattern.R_PREFIX_MATCH, - scope, collector, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); - assertEquals(4, collector.matches.size()); - } finally { - deleteProject("P"); - } - } - public void testBug483650_0004() throws Exception { - IJavaProject project = null; - try - { - // create the common project and create an interface - project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin","1.5"); - createFolder("P/src/p478042"); - createFile("/P/src/p478042/AllMethodDeclarations01.java", - "package p478042;\n" + - "class Y {}\n" + - "class X {}\n" + - "public class AllMethodDeclarations01 {\n" + - " public Y foo01(Y t) {}\n" + - " public int foo02(Object o) {return null;}\n" + - " public char foo03(Object o, String s) {return null;}\n" + - "}"); - createFile("/P/src/p478042/AllMethodDeclarations01b.java", - "package p478042;\n" + - "public class AllMethodDeclarations01b {\n" + - " public Integer fooInt() {return null;}\n" + - "}"); - MethodNameMatchCollector collector = new MethodNameMatchCollector() { - @Override - public String toString() { - return toFullyQualifiedNamesString(); - } - }; - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.SOURCES); - searchAllMethodNames("*", SearchPattern.R_PATTERN_MATCH, "foo", SearchPattern.R_PREFIX_MATCH, scope, collector); - assertSearchResults( - "/P/src/p478042/AllMethodDeclarations01.java Y p478042.AllMethodDeclarations01.foo01(Y t)\n" + - "/P/src/p478042/AllMethodDeclarations01.java char p478042.AllMethodDeclarations01.foo03(Object o,String s)\n" + - "/P/src/p478042/AllMethodDeclarations01.java int p478042.AllMethodDeclarations01.foo02(Object o)\n" + - "/P/src/p478042/AllMethodDeclarations01b.java Integer p478042.AllMethodDeclarations01b.fooInt()", - collector - ); - } finally { - deleteProject(project); - } - } - public void testBug483650_005() throws Exception { - try { - IJavaProject p = createJavaProject("P", new String[] {}, new String[] { "/P/lib478042.jar", "JCL15_LIB" }, "", "1.5"); - createJar(new String[] { - "p478042/AllMethodDeclarations02.java", - "package p478042;\n" + - "class X {}\n" + - "class Y{}\n" + - "public class AllMethodDeclarations02 {\n" + - " public Y foo01(Y t) { return null;}\n" + - " public int foo02(Object o) {return 0;}\n" + - " public char foo03(Object o, String s) {return '0';}\n" + - "}", - "p478042/AllMethodDeclarations02b.java", - "package p478042;\n" + - "class AllMethodDeclarations02b {\n" + - " public void fooInt() {}\n" + - "}" - }, p.getProject().getLocation().append("lib478042.jar").toOSString(), - new String[] { p.getProject().getLocation().append("lib478042.jar").toOSString() }, - "1.5"); - refresh(p); - - MethodNameMatchCollector collector = new MethodNameMatchCollector() { - @Override - public String toString() { - return toFullyQualifiedNamesString(); - } - }; - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES|IJavaSearchScope.APPLICATION_LIBRARIES); - searchAllMethodNames("*", SearchPattern.R_PATTERN_MATCH, "foo", SearchPattern.R_PREFIX_MATCH, scope, collector); - assertSearchResults( - "/P/lib478042.jar p478042.Y p478042.AllMethodDeclarations02.foo01(p478042.Y t)\n" + - "/P/lib478042.jar void p478042.AllMethodDeclarations02b.fooInt()\n" + - "/P/lib478042.jar int p478042.AllMethodDeclarations02.foo02(java.lang.Object o)\n" + - "/P/lib478042.jar char p478042.AllMethodDeclarations02.foo03(java.lang.Object o,java.lang.String s)", - collector - ); - } finally { - deleteProject("P"); - } - } - public void testBug483650_006() throws Exception { - try { - IJavaProject p = createJavaProject("P", new String[] {}, new String[] { "/P/lib478042.jar", "JCL15_LIB" }, "", "1.5"); - createJar(new String[] { - "p478042/AllMethodDeclarations01.java", - "package p478042;\n" + - "public class AllMethodDeclarations01 {\n" + - " public class Nested {\n" + - " public class Inner {\n" + - " public void foo01() {}\n" + - " public int foo02(Object o) {return 0;}\n" + - " public char foo03(Object o, String s) {return '0';}\n" + - " }\n" + - " }\n" + - "}\n" - }, p.getProject().getLocation().append("lib478042.jar").toOSString(), - new String[] { p.getProject().getLocation().append("lib478042.jar").toOSString() }, - "1.5"); - refresh(p); - - MethodNameMatchCollector collector = new MethodNameMatchCollector() { - @Override - public String toString() { - return toFullyQualifiedNamesString(); - } - }; - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES|IJavaSearchScope.APPLICATION_LIBRARIES); - searchAllMethodNames("*", SearchPattern.R_PATTERN_MATCH, "foo", SearchPattern.R_PREFIX_MATCH, scope, collector); - assertSearchResults( - "/P/lib478042.jar void p478042.AllMethodDeclarations01.Nested.Inner.foo01()\n" + - "/P/lib478042.jar int p478042.AllMethodDeclarations01.Nested.Inner.foo02(java.lang.Object o)\n" + - "/P/lib478042.jar char p478042.AllMethodDeclarations01.Nested.Inner.foo03(java.lang.Object o,java.lang.String s)", - collector - ); - } finally { - deleteProject("P"); - } - } - public void testBug483650_007() throws Exception { - try { - IJavaProject p = createJavaProject("P", new String[] {}, new String[] { "/P/lib478042.jar", "JCL15_LIB" }, "", "1.5"); - createJar(new String[] { - "p478042/AllMethodDeclarations01.java", - "package p478042;\n" + - "public class AllMethodDeclarations01 {\n" + - " public class Nested {\n" + - " public class Inner {\n" + - " public void foo01() {}\n" + - " public int foo02(Object o) {return 0;}\n" + - " public char foo03(Object o, String s) {return '0';}\n" + - " }\n" + - " }\n" + - "}\n" - }, p.getProject().getLocation().append("lib478042.jar").toOSString(), - new String[] { p.getProject().getLocation().append("lib478042.jar").toOSString() }, - "1.5"); - refresh(p); - - MethodNameMatchCollector collector = new MethodNameMatchCollector() { - @Override - public String toString() { - return toFullyQualifiedNamesString(); - } - }; - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES|IJavaSearchScope.APPLICATION_LIBRARIES); - searchAllMethodNames( - "*Inner", SearchPattern.R_PATTERN_MATCH, - "foo", SearchPattern.R_PREFIX_MATCH, scope, collector); - assertSearchResults( - "/P/lib478042.jar void p478042.AllMethodDeclarations01.Nested.Inner.foo01()\n" + - "/P/lib478042.jar int p478042.AllMethodDeclarations01.Nested.Inner.foo02(java.lang.Object o)\n" + - "/P/lib478042.jar char p478042.AllMethodDeclarations01.Nested.Inner.foo03(java.lang.Object o,java.lang.String s)", - collector - ); - } finally { - deleteProject("P"); - } - } - public void testBug483650_008() throws Exception { - IJavaProject project = null; - try - { - // create the common project and create an interface - project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin","1.5"); - createFolder("P/src/p478042"); - createFile("/P/src/p478042/AllMethodDeclarations01.java", - "package p478042;\n" + - "public class AllMethodDeclarations01 {\n" + - " public class Nested {\n" + - " public class Inner {\n" + - " public void foo01() {}\n" + - " public int foo02(Object o) {return 0;}\n" + - " public char foo03(Object o, String s) {return '0';}\n" + - " }\n" + - " }\n" + - "}"); - MethodNameMatchCollector collector = new MethodNameMatchCollector() { - @Override - public String toString() { - return toFullyQualifiedNamesString(); - } - }; - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.SOURCES); - searchAllMethodNames("*", SearchPattern.R_PATTERN_MATCH, "foo", SearchPattern.R_PREFIX_MATCH, scope, collector); - assertTrue(collector.matches.size() == 3); - } catch(Exception e) { - e.printStackTrace(); - } finally { - deleteProject(project); - } - } - public void testBug483650_009() throws Exception { - IJavaProject project = null; - try { - project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin","1.5"); - createFolder("P/src/p478042"); - createFile("/P/src/p478042/AllMethodDeclarations01.java", - "package p478042;\n" + - "public class AllMethodDeclarations01 {\n" + - " public void m1(int i) {}\n" + - " public void foo01() {}\n" + - " public int foo02(Object o) {return null;}\n" + - " public char foo03(Object o, String s) {return null;}\n" + - " }"); - createFile("/P/src/p478042/AllMethodDeclarations01b.java", - "package p478042;\n" + - "public class AllMethodDeclarations01b {\n" + - " public Integer fooInt() {return null;}\n" + - " }"); - class Collector extends MethodNameMatchRequestor { - List matches = new ArrayList<>(); - @Override - public void acceptMethodNameMatch(MethodNameMatch match) { - this.matches.add(match); - } - } - IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.SOURCES); - Collector collector = new Collector(); - new SearchEngine().searchAllMethodNames( - "*.AllMethodDeclarations01".toCharArray(), SearchPattern.R_PATTERN_MATCH, - "m1".toCharArray(), SearchPattern.R_PREFIX_MATCH, - scope, collector, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); - assertEquals(1, collector.matches.size()); - IMethod method = collector.matches.get(0).getMethod(); - assertTrue(method.exists()); - } finally { - deleteProject("P"); - } - } - public void testBug489404() throws CoreException, IOException { - try { - IJavaProject p = createJavaProject("P", new String[] { "src" }, new String[] { "/P/p1p2.jar", "JCL15_LIB" }, "bin", "1.5"); - org.eclipse.jdt.core.tests.util.Util.createJar(new String[] { - "p1/MissingClass.java", - "package p1;\n" + - "public class MissingClass{}\n" }, - p.getProject().getLocation().append("p1.jar").toOSString(), "1.5"); - - org.eclipse.jdt.core.tests.util.Util.createJar(new String[] { - "p1/p2/BinaryWithField.java", - "package p1.p2;\n" + - "import p1.MissingClass;\n" + - "public class BinaryWithField {\n" + - " public class Binary {\n" + - " }\n" + - " MissingClass f;\n" + - "}\n", - "p1/p2/BinaryWithMethod.java", - "package p1.p2;\n" + - "import p1.MissingClass;\n" + - "public class BinaryWithMethod {\n" + - " public class Binary {\n" + - " }\n" + - " MissingClass m() {\n" + - " return null;\n" + - " }\n" + - "}\n"}, - null, - p.getProject().getLocation().append("p1p2.jar").toOSString(), - new String[] { p.getProject().getLocation().append("p1.jar").toOSString() }, - "1.5"); - createFolder("/P/src/test"); - createFile("/P/src/test/A.java", - "package test;\n" + - "import p1.MissingClass;\n" + - "public class A {\n" + - " MissingClass m() {\n" + - " return null;\n" + - " }\n" + - "}\n"); - createFile("/P/src/test/TestSearchBug.java", - "package test;\n" + - "\n" + - "public class TestSearchBug {\n" + - " public String lang;\n" + - "}\n"); - refresh(p); - waitUntilIndexesReady(); - IType type = getCompilationUnit("/P/src/test/TestSearchBug.java").getType("TestSearchBug"); - IField field = type.getField("lang"); - search(field, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults( - "Unexpected search results!", - "", - this.resultCollector); - } finally { - deleteProject("P"); - } - } - public void testBug491656_001() throws CoreException, IOException { - try { - IJavaProject p = createJavaProject("P", new String[] { "src" }, new String[] { "JCL15_LIB", "/P/lib491656_001.jar" }, "bin", "1.5"); - String libsource = "package p2;\n" + - "import java.util.HashMap;\n"+ - "import java.util.Map;\n"+ - "\n"+ - "public class MyLinkedHashMap\n"+ - " extends HashMap\n"+ - " implements Map\n"+ - "{\n"+ - " private transient Entry header;\n"+ - " public MyLinkedHashMap(int initialCapacity, float loadFactor) {\n"+ - " super(initialCapacity, loadFactor);\n"+ - " }\n"+ - " private static class Entry {\n"+ - " public Object hash;\n"+ - " Entry before, after;\n"+ - "\n"+ - " Entry(int hash, K key, V value, HashMap.Entry next) {}\n"+ - " private void remove491656() {}\n"+ - " private void remove491656Test() {}\n"+ - "\n"+ - " private void addBefore491656(Entry existingEntry) {}\n"+ - " public void iamAPublicMethod491656(Entry existingEntry) {}\n"+ - "\n"+ - " void recordAccess(HashMap m) {\n"+ - " MyLinkedHashMap lm = (MyLinkedHashMap)m;\n"+ - " remove491656();\n"+ - " remove491656Test();\n"+ - " addBefore491656(lm.header);\n"+ - " iamAPublicMethod491656(lm.header);\n"+ - " }\n"+ - " }\n"+ - "}\n"; - String jarFileName = "lib491656_001.jar"; - String srcZipName = "lib491656_001.src.zip"; - createLibrary(p, jarFileName, srcZipName, new String[] {"p2/MyLinkedHashMap.java",libsource}, new String[0], JavaCore.VERSION_1_5); - IFile srcZip=(IFile) p.getProject().findMember(srcZipName); - IFile jar = (IFile) p.getProject().findMember(jarFileName); - p.getPackageFragmentRoot(jar).attachSource(srcZip.getFullPath(), null, null); - refresh(p); - waitUntilIndexesReady(); - IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); - IType enclosingType = p.findType("p2.MyLinkedHashMap"); - IType[] types = enclosingType.getTypes(); - IMethod[] methods = types[0].getMethods(); - IMethod method = methods[3]; - assertTrue("Wrong Method", method.toString().contains("addBefore491656")); - SearchPattern pattern = SearchPattern.createPattern(method, REFERENCES); - MatchLocator.setFocus(pattern, method); - new SearchEngine(this.workingCopies).search( - pattern, - new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, - getJavaSearchScope(), - this.resultCollector, - null - ); - search(pattern, scope, this.resultCollector); - assertSearchResults( - "lib491656_001.jar void p2.MyLinkedHashMap$Entry.recordAccess(java.util.HashMap) EXACT_MATCH"); - } finally { - deleteProject("P"); - } - } - - /** - * Test that a diamond in a type name doesn't result in an AIOOBE during a search. - * See: https://github.com/eclipse-jdt/eclipse.jdt.core/issues/825 - */ - public void testOutOfBoundsIndexExceptionDuringSearchGh825() throws Exception { - String projectName = "testGh825"; - try { - IJavaProject project = createJavaProject(projectName, new String[] {"src"}, new String[] {"JCL11_LIB"}, "bin", "11"); - String srcFolder = "/" + projectName + "/src/"; - String packageFolder = srcFolder + "test"; - createFolder(packageFolder); - String snippet = String.join(System.lineSeparator(), new String[] { - "package test;", - "public class Test {", - " public interface TestInterface {", - " void testMethod(T t);", - " }", - " TestInterface SUP = new TestInterface<>() {", - " public void testMethod(String s) {}", - " };", - " static void shouldFail() {}", - "}", - }); - createFile(packageFolder + "/Test.java", snippet); - - String module = "module tester {}"; - createFile(srcFolder + "/module-info.java", module); - - String testFolder = "/" + projectName + "/test"; - createFolder(testFolder); - IClasspathAttribute[] testAttrs = { JavaCore.newClasspathAttribute(IClasspathAttribute.TEST, Boolean.toString(true)) }; - addClasspathEntry(project, JavaCore.newSourceEntry( - new Path(testFolder), - null, - null, - new Path("/" + projectName + "/bin-test"), - testAttrs)); - - addLibrary(project, - "libGh825.jar", - "libGh825.src.zip", - new String[] { - "testpackage/TestClass.java", - "package testpackage;\n" + - "public class TestClass {}" - }, - JavaCore.VERSION_11); - - buildAndExpectNoProblems(project); - IType type = project.findType("test.Test"); - IMethod method = type.getMethod("shouldFail", new String[0]); - search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - // we expect no matches and no exceptions - assertSearchResults(""); - } finally { - deleteProject(projectName); - } - } - - /** - * Test that an inner class constructor with first argument of the outer type - * doesn't result in no search matches. - * See: https://github.com/eclipse-jdt/eclipse.jdt.core/issues/401 - */ - public void testInnerConstructorWithOuterTypeArgumentGh401() throws Exception { - String projectName = "testGh401"; - try { - IJavaProject project = createJavaProject(projectName, new String[] {"src"}, new String[] {"JCL11_LIB"}, "bin", "11"); - String srcFolder = "/" + projectName + "/src/"; - String packageFolder = srcFolder + "test1"; - createFolder(packageFolder); - String snippet1 = - """ - package test1; - public final class Outer1 { - public void staticConstructorCaller() { - new StaticInner1(this); - } - public void constructorCaller() { - new Inner1(this); - } - private static final class StaticInner1 { - StaticInner1(Outer1 o) {} - } - private final class Inner1 { - Inner1(Outer1 o) {} - } - } - """; - createFile(packageFolder + "/Outer1.java", snippet1); - - addLibrary(project, - "libGh401.jar", - "libGh401.src.zip", - new String[] { - "test2/Outer2.java", - """ - package test2; - public final class Outer2 { - public void staticConstructorCaller() { - new StaticInner2(this); - } - public void constructorCaller() { - new Inner2(this); - } - private static final class StaticInner2 { - StaticInner2(Outer2 o) {} - } - private final class Inner2 { - Inner2(Outer2 o) {} - } - } - """, - }, - JavaCore.VERSION_11); - - buildAndExpectNoProblems(project); - - String[] typesAndExpcetedMatches = { - "test1.Outer1.StaticInner1", - "src/test1/Outer1.java void test1.Outer1.staticConstructorCaller() [new StaticInner1(this)] EXACT_MATCH", - "test1.Outer1.Inner1", - "src/test1/Outer1.java void test1.Outer1.constructorCaller() [new Inner1(this)] EXACT_MATCH", - "test2.Outer2.StaticInner2", - "libGh401.jar void test2.Outer2.staticConstructorCaller() EXACT_MATCH", - "test2.Outer2.Inner2", - "libGh401.jar void test2.Outer2.constructorCaller() EXACT_MATCH", - - }; - - for (int i = 0; i < typesAndExpcetedMatches.length; i += 2) { - String type = typesAndExpcetedMatches[i + 0]; - String expectedMatch = typesAndExpcetedMatches[i + 1]; - IType staticInnerType = project.findType(type); - IMethod staticInnerConstructor = staticInnerType.getMethods()[0]; - search(staticInnerConstructor, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults(expectedMatch); - this.resultCollector.clear(); - } - } finally { - deleteProject(projectName); - } - } - - /** - *
For the following scenario, no call hierarchy is found:
- * A nested private class implements a public nested interface. - * The overridden method from the interface also has an argument of the interface type. - * No call hierarchy is found for the overridden method, when searching from within the nested class. - * See: https://github.com/eclipse-jdt/eclipse.jdt.core/issues/821 - */ - public void testCallHierarchyWithNestedInterfacesGh821() throws Exception { - String projectName = "TestCallHierarchyWithNestedInterfacesGh821"; - try { - IJavaProject project = createJavaProject(projectName, new String[] { "src" }, new String[] { "JCL15_LIB" }, "bin", "1.5"); - String packageFolder = "/" + projectName + "/src/test"; - createFolder(packageFolder); - String snippet1 = - """ - package test; - public class TestNestedPrivateClass { - public NestedInterface nm = new NC(); - public interface NestedInterface { - public void foo(NestedInterface arg); - } - private final class NC implements NestedInterface { - public void foo(NestedInterface arg) {} - } - } - """; - createFile(packageFolder + "/TestNestedPrivateClass.java", snippet1); - String snippet2 = - """ - package test; - public class TestReferencingClass { - public static void bar() { - TestNestedPrivateClass c = new TestNestedPrivateClass(); - TestNestedPrivateClass.NestedInterface nestedMember = c.nm; - nestedMember.foo(nestedMember); - } - } - """; - createFile(packageFolder + "/TestReferencingClass.java", snippet2); - buildAndExpectNoProblems(project); - IType type = project.findType("test.TestNestedPrivateClass.NC"); - IMethod[] methods = type.getMethods(); - assertEquals("Expected one method in: " + Arrays.asList(methods), 1, methods.length); - search(methods[0], REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); - assertSearchResults( - "src/test/TestReferencingClass.java void test.TestReferencingClass.bar() [foo(nestedMember)] EXACT_MATCH"); - } finally { - deleteProject(projectName); - } - } - - private static void printJavaElements(IJavaProject javaProject, PrintStream output) throws Exception { - output.println("Printing Java elements of Java project: " + javaProject); - List queue = new LinkedList<>(); - while (!queue.isEmpty()) { - IJavaElement element = queue.remove(queue.size() - 1); - output.println(element); - output.print(element); - if (element instanceof IParent) { - IParent parent = (IParent) element; - queue.addAll(Arrays.asList(parent.getChildren())); - } - } - } - - private static void printZipContents(File jarFile, PrintStream output) throws Exception { - if (jarFile.exists()) { - output.println("Listing contents of jar file: " + jarFile); - try (ZipFile zipFile = new ZipFile(jarFile)) { - Enumeration entries = zipFile.entries(); - while (entries.hasMoreElements()) { - ZipEntry zipEntry = entries.nextElement(); - String zipEntryName = zipEntry.getName(); - output.println("Listing contents of zip entry: " + zipEntryName); - InputStream zipEntryInputStream = zipFile.getInputStream(zipEntry); - if (zipEntryName.endsWith(".class")) { - byte[] classFileBytes = toByteArray(zipEntryInputStream); - ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); - String classContents = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); - output.println(classContents); - } else { - @SuppressWarnings("resource") // the zip file resource-try will close the stream - Scanner scanner = new Scanner(zipEntryInputStream); - while (scanner.hasNextLine()) { - output.println(scanner.nextLine()); - } - } - } - } - } else { - output.println("File does not exist: " + jarFile); - } - } - - private static byte[] toByteArray(InputStream inputStream) throws IOException { - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - byte[] data = new byte[8192]; - - int nRead; - while ((nRead = inputStream.read(data, 0, data.length)) != -1) { - buffer.write(data, 0, nRead); - } - - return buffer.toByteArray(); - } - - private void assertUTF8Encoding() { - String fileEncodingVMProperty = System.getProperty("file.encoding"); - Charset defaultCharset = Charset.defaultCharset(); - String langEnvVariable = System.getenv("LANG"); - StringBuilder errorMessage = new StringBuilder(); - errorMessage.append(System.lineSeparator()); - errorMessage.append("Unexpected encoding during test, encoding parameters are:"); - errorMessage.append(System.lineSeparator()); - errorMessage.append("-Dfile.encoding=" + fileEncodingVMProperty); - errorMessage.append(System.lineSeparator()); - errorMessage.append("Charset.defaultCharset()=" + defaultCharset); - errorMessage.append(System.lineSeparator()); - errorMessage.append("LANG=" + langEnvVariable); - - assertEquals("unexpected default charset " + errorMessage, StandardCharsets.UTF_8, defaultCharset); - if (Constants.OS_LINUX.equals(System.getProperty("osgi.os"))) { - assertNotNull("expected LANG environment variable to be set" + errorMessage, langEnvVariable); - String utf8LANGRegexp = ".*\\.(UTF-8|UTF8|utf-8|utf8)"; - Pattern utf8LANGPattern = Pattern.compile(utf8LANGRegexp); - Matcher LANGMatcher = utf8LANGPattern.matcher(langEnvVariable); - assertTrue("expected encoding set with LANG environment variable to match regexp: " + utf8LANGRegexp + ", LANG=" + langEnvVariable + errorMessage, - LANGMatcher.matches()); - } - } +/******************************************************************************* + * Copyright (c) 2014, 2016 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + * Stephan Herrmann - Contribution for + * Bug 377883 - NPE on open Call Hierarchy + *******************************************************************************/ + +package org.eclipse.jdt.core.tests.model; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintStream; +import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Enumeration; +import java.util.LinkedList; +import java.util.List; +import java.util.Scanner; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jdt.core.IAccessRule; +import org.eclipse.jdt.core.IClasspathAttribute; +import org.eclipse.jdt.core.IClasspathEntry; +import org.eclipse.jdt.core.ICompilationUnit; +import org.eclipse.jdt.core.IField; +import org.eclipse.jdt.core.IJavaElement; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.IMethod; +import org.eclipse.jdt.core.IParent; +import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.core.ToolFactory; +import org.eclipse.jdt.core.search.IJavaSearchConstants; +import org.eclipse.jdt.core.search.IJavaSearchScope; +import org.eclipse.jdt.core.search.MethodNameMatch; +import org.eclipse.jdt.core.search.MethodNameMatchRequestor; +import org.eclipse.jdt.core.search.SearchEngine; +import org.eclipse.jdt.core.search.SearchMatch; +import org.eclipse.jdt.core.search.SearchParticipant; +import org.eclipse.jdt.core.search.SearchPattern; +import org.eclipse.jdt.core.search.TypeNameMatch; +import org.eclipse.jdt.core.search.TypeNameMatchRequestor; +import org.eclipse.jdt.core.util.ClassFileBytesDisassembler; +import org.eclipse.jdt.internal.core.search.matching.MatchLocator; +import org.eclipse.jdt.internal.core.search.matching.MethodPattern; +import org.eclipse.osgi.service.environment.Constants; + +import junit.framework.Test; + +// The size of JavaSearchBugsTests.java is very big, Hence continuing here. +@SuppressWarnings({"rawtypes", "unchecked"}) +public class JavaSearchBugsTests2 extends AbstractJavaSearchTests { + + public JavaSearchBugsTests2(String name) { + super(name); + this.endChar = ""; + } + + static { + //TESTS_NAMES = new String[] {"testBug378390"}; + } + + public static Test suite() { + return buildModelTestSuite(JavaSearchBugsTests2.class); + } + + class TestCollector extends JavaSearchResultCollector { + public List matches = new ArrayList(); + + @Override + public void acceptSearchMatch(SearchMatch searchMatch) throws CoreException { + super.acceptSearchMatch(searchMatch); + this.matches.add(searchMatch); + } + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + this.resultCollector = new TestCollector(); + this.resultCollector.showAccuracy(true); + } + + /** + * Test that missing types in the class shouldn't impact the search of a type in an inner class + */ + public void testBug362633() throws CoreException, IOException { + try { + IJavaProject p = createJavaProject("P", new String[] {}, new String[] { "/P/lib325418.jar", "JCL15_LIB" }, "", "1.5"); + org.eclipse.jdt.core.tests.util.Util.createJar(new String[] { + "p325418M/Missing.java", + "package p325418M;\n" + + "public class Missing{}\n" }, + p.getProject().getLocation().append("lib325418M.jar").toOSString(), "1.5"); + + org.eclipse.jdt.core.tests.util.Util.createJar( + new String[] { + "p325418/Test.java", + "package p325418;\n" + + "public class Test{\n" + + " public void foo(p325418M.Missing a) {}\n" + + " public T foo(int a) {\n" + + " return new Inner() {T run() { return null; }}.run();\n" + + " }\n" + "}\n", + "p325418/Inner.java", + "package p325418;\n" + + "abstract class Inner {\n" + + " abstract T run();\n" + "}\n" }, + null, + p.getProject().getLocation().append("lib325418.jar").toOSString(), + new String[] { p.getProject().getLocation().append("lib325418M.jar").toOSString() }, + "1.5"); + refresh(p); + int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES; + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, mask); + search("Inner.run()", IJavaSearchConstants.METHOD, IJavaSearchConstants.DECLARATIONS, scope, this.resultCollector); + assertSearchResults( + "Unexpected search results!", + "lib325418.jar T p325418.Inner.run() [No source] EXACT_MATCH\n" + + "lib325418.jar T p325418..run() [No source] EXACT_MATCH", + this.resultCollector); + } finally { + deleteProject("P"); + } + } + + /** + * @bug 123836: [1.5][search] for references to overriding method with bound type variable is not polymorphic + * @test Search for references to an overridden method with bound variables should yield. + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=123836" + */ + public void testBug123836a() throws CoreException { + IJavaProject project = null; + try + { + project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); + createFile("/P/Sub.java", + "abstract class Sup {\n" + + " protected void m(C classifier) {}\n"+ + " public void use(C owner) { m (owner); }\n" + + "}\n" + + "public class Sub extends Sup{\n" + + " @Override\n"+ + " protected void m(String classifier) {}\n"+ + "}\n"); + IType type = getCompilationUnit("/P/Sub.java").getType("Sub"); + IMethod method = type.getMethod("m", new String[]{"QString;"}); + search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults("Sub.java void Sup.use(C) [m (owner)] EXACT_MATCH"); + } finally { + deleteProject(project); + } + } + // Search for a non-overridden method with same name as which could have been overridden should + // not have results + public void testBug123836b() throws CoreException { + IJavaProject project = null; + try + { + project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); + createFile("/P/Sub.java", + "abstract class Sup {\n" + + " protected void m(C classifier) {}\n"+ + " public void use(C owner) { m (owner); }\n" + + "}\n" + + "public class Sub extends Sup{\n" + + " @Override\n"+ + " protected void m(String classifier) {}\n"+ + " protected void m(Sub classifier) {}\n"+ + "}\n" ); + // search + IType type = getCompilationUnit("/P/Sub.java").getType("Sub"); + IMethod method = type.getMethod("m", new String[]{"QSub;"}); + search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults(""); + + } finally { + deleteProject(project); + } + } + // another variant of the testcase + public void testBug123836c() throws CoreException { + IJavaProject project = null; + try + { + // create the common project and create an interface + project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); + createFile("/P/Test.java", + "class Test {\n"+ + " void calc(Property prop, Property p2) {\n"+ + " prop.compute(null);\n"+ + " p2.compute(null);\n"+ + " }\n"+ + "}\n"+ + "abstract class Property {\n"+ + " public abstract void compute(E e);\n"+ + "}\n"+ + "class StringProperty extends Property {\n"+ + " @Override public void compute(String e) {\n"+ + " System.out.println(e);\n"+ + " }"); + IType type = getCompilationUnit("/P/Test.java").getType("StringProperty"); + IMethod method = type.getMethod("compute", new String[]{"QString;"}); + search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults("Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH\n" + + "Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH"); + } finally { + deleteProject(project); + } + } + // Test inner class + public void testBug123836d() throws CoreException { + IJavaProject project = null; + try + { + // create the common project and create an interface + project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); + createFile("/P/Test.java", + "class Test {\n"+ + " void calc(Property prop, Property p2) {\n"+ + " prop.compute(null);\n"+ + " p2.compute(null);\n"+ + " }\n"+ + " class StringProperty extends Property {\n"+ + " @Override public void compute(String e) {\n"+ + " System.out.println(e);\n"+ + " }\n"+ + "}\n"+ + "abstract class Property {\n"+ + " public abstract void compute(E e);\n"+ + "}"); + + IType type = getCompilationUnit("/P/Test.java").getType("Test").getType("StringProperty"); + IMethod method = type.getMethod("compute", new String[]{"QString;"}); + search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults("Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH\n" + + "Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH"); + } finally { + deleteProject(project); + } + } + // Test local class + public void testBug123836e() throws CoreException { + IJavaProject project = null; + try + { + // create the common project and create an interface + project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); + createFile("/P/Test.java", + "class Test {\n"+ + " void calc(Property prop, Property p2) {\n"+ + " prop.compute(null);\n"+ + " p2.compute(null);\n"+ + " class StringProperty extends Property {\n"+ + " @Override public void compute(String e) {\n"+ + " System.out.println(e);\n"+ + " }\n"+ + " }\n"+ + " }\n"+ + "}\n"+ + "abstract class Property {\n"+ + " public abstract void compute(E e);\n"+ + "}"); + IMethod method = selectMethod(getCompilationUnit("/P/Test.java"), "compute", 3); + search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults("Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH\n" + + "Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH"); + } finally { + deleteProject(project); + } + } + // test inner class + public void testBug123836f() throws CoreException { + IJavaProject project = null; + try + { + // create the common project and create an interface + project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); + createFile("/P/Test.java", + "class Test {\n"+ + " void calc(Property prop, Property p2) {\n"+ + " prop.compute(null);\n"+ + " p2.compute(null);\n"+ + " new Property() {\n"+ + " @Override public void compute(String e) {\n"+ + " System.out.println(e);\n"+ + " }\n"+ + " };\n"+ + " }\n"+ + "}\n"+ + "abstract class Property {\n"+ + " public abstract void compute(E e);\n"+ + "}"); + IMethod method = selectMethod(getCompilationUnit("/P/Test.java"), "compute", 3); + search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults("Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH\n" + + "Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH"); + } finally { + deleteProject(project); + } + } + // test in initializer block + public void testBug123836g() throws CoreException { + IJavaProject project = null; + try + { + // create the common project and create an interface + project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); + createFile("/P/Test.java", + "class Test {\n"+ + " {\n" + + " new Property() {\n" + + " @Override public void compute(String e) {}\n" + + " };\n"+ + " }\n"+ + " void calc(Property prop, Property p2) {\n"+ + " prop.compute(null);\n"+ + " p2.compute(null);\n"+ + " }\n"+ + "}\n"+ + "abstract class Property {\n"+ + " public abstract void compute(E e);\n"+ + "}"); + IMethod method = selectMethod(getCompilationUnit("/P/Test.java"), "compute", 1); + search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults("Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH\n" + + "Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH"); + } finally { + deleteProject(project); + } + } + // test in static initializer + public void testBug123836h() throws CoreException { + IJavaProject project = null; + try + { + // create the common project and create an interface + project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); + createFile("/P/Test.java", + "class Test {\n"+ + " static {\n" + + " new Property() {\n" + + " @Override public void compute(String e) {}\n" + + " };\n"+ + " }\n"+ + " void calc(Property prop, Property p2) {\n"+ + " prop.compute(null);\n"+ + " p2.compute(null);\n"+ + " }\n"+ + "}\n"+ + "abstract class Property {\n"+ + " public abstract void compute(E e);\n"+ + "}"); + IMethod method = selectMethod(getCompilationUnit("/P/Test.java"), "compute", 1); + search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults("Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH\n" + + "Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH"); + } finally { + deleteProject(project); + } + } + // test in static initializer + public void testBug123836i() throws CoreException { + IJavaProject project = null; + try + { + // create the common project and create an interface + project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); + createFile("/P/Test.java", + "class Test {\n"+ + " Property p = new Property() {\n" + + " @Override public void compute(String e) {}\n" + + " };\n"+ + " void calc(Property prop, Property p2) {\n"+ + " prop.compute(null);\n"+ + " p2.compute(null);\n"+ + " }\n"+ + "}\n"+ + "abstract class Property {\n"+ + " public abstract void compute(E e);\n"+ + "}"); + IMethod method = selectMethod(getCompilationUnit("/P/Test.java"), "compute", 1); + search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults("Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH\n" + + "Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH"); + } finally { + deleteProject(project); + } + } + public void testBug123836j() throws CoreException { + IJavaProject project = null; + try + { + // create the common project and create an interface + project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); + createFile("/P/Test.java", + "class Test {\n"+ + " void calc(Property prop, Property p2) {\n"+ + " prop.compute(null);\n"+ + " p2.compute(null);\n"+ + " }\n"+ + "}\n"+ + "abstract class Property {\n"+ + " public abstract void compute(E e);\n"+ + "}\n"+ + "class StringProperty extends Property {\n"+ + " @Override public void compute(String e) {\n"+ + " new Property() {\n"+ + " @Override public void compute(String e) {\n"+ + " new Property() {\n"+ + " @Override public void compute(String e) {}\n"+ + " };\n"+ + " }\n"+ + " };\n"+ + " }\n"+ + "}"); + IMethod method = selectMethod(getCompilationUnit("/P/Test.java"), "compute", 6); + search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults("Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH\n" + + "Test.java void Test.calc(Property, Property) [compute(null)] EXACT_MATCH"); + } finally { + deleteProject(project); + } + } + // test search of name + public void _testBug123836g1() throws CoreException { + IJavaProject project = null; + try + { + // create the common project and create an interface + project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); + createFile("/P/Sub.java", + "abstract class Sup {\n" + + " protected void m(C classifier) {}\n"+ + " public void use(C owner) { m (owner); }\n" + + "}\n" + + "public class Sub extends Sup{\n" + + " @Override\n"+ + " protected void m(String classifier) {}\n"+ + " protected void m(Sub classifier) {}\n"+ + "}\n" ); + waitUntilIndexesReady(); + // search + SearchPattern pattern = SearchPattern.createPattern("Sub.m(String)", METHOD, REFERENCES, EXACT_RULE); + search(pattern, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults("Sub.java void Sup.use(C) [m (owner)] EXACT_MATCH"); + + } finally { + deleteProject(project); + } + } + // test search of name (negative) + public void _testBug123836h1() throws CoreException { + IJavaProject project = null; + try + { + // create the common project and create an interface + project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); + createFile("/P/Sub.java", + "abstract class Sup {\n" + + " protected void m(C classifier) {}\n"+ + " public void use(C owner) { m (owner); }\n" + + "}\n" + + "public class Sub extends Sup{\n" + + " @Override\n"+ + " protected void m(String classifier) {}\n"+ + " protected void m(Sub classifier) {}\n"+ + "}\n" ); + // search + SearchPattern pattern = SearchPattern.createPattern("Sub.m(Sub)", METHOD, REFERENCES, EXACT_RULE); + search(pattern, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults(""); + + } finally { + deleteProject(project); + } + } + /** + * @bug 297825: [search] Rename refactoring doesn't update enclosing type + * @test Search for references for enclosing type's subclass should return a match. + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=297825" + */ + public void testBug297825a() throws CoreException { + try { + IJavaProject p = createJavaProject("P", new String[] { "src" }, + new String[] {"JCL_LIB"}, "bin"); + createFolder("/P/src/b297825"); + createFile("/P/src/b297825/_Foo.java", + "package b297825;\n" + + "public class _Foo {\n" + + " public static class Bar {\n" + + " }\n" + + "}" + ); + createFile("/P/src/b297825/Foo.java", + "package b297825;\n" + + "public class Foo extends _Foo {\n" + + "}\n" + ); + createFile("/P/src/b297825/Main.java", + "package b297825;\n" + + "public class Main {\n" + + " public static void main(String[] args) {\n" + + " new Foo.Bar();\n" + + " }\n" + + "}" + ); + waitUntilIndexesReady(); + IType type = getCompilationUnit("/P/src/b297825/Foo.java").getType("Foo"); + IJavaSearchScope scope = SearchEngine + .createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES); + + search(type, REFERENCES, scope, this.resultCollector); + + assertSearchResults("src/b297825/Main.java void b297825.Main.main(String[]) [Foo] EXACT_MATCH"); + } finally { + deleteProject("P"); + } + } + /** + * @bug 297825: [search] Rename refactoring doesn't update enclosing type + * @test Verify there is no AIOOB when searching for references for a type. + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=297825" + */ + public void testBug297825b() throws CoreException { + try { + IJavaProject p = createJavaProject("P", new String[] { "src" }, + new String[] {"JCL_LIB"}, "bin"); + createFile("/P/src/Foo.java", + "class _Foo {\n" + + " public static class Bar {\n" + + " }\n" + + "}" + + "public class Foo extends _Foo {\n" + + " public static class FooBar {\n" + + " }\n" + + "}" + + "class Main {\n" + + " public static void main(String[] args) {\n" + + " new Foo.Bar();\n" + + " new Foo.FooBar();\n" + + " }\n" + + "}" + ); + waitUntilIndexesReady(); + IType type = getCompilationUnit("/P/src/Foo.java").getType("Foo"); + IJavaSearchScope scope = SearchEngine + .createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES); + + search(type, REFERENCES, scope, this.resultCollector); + + assertSearchResults("src/Foo.java void Main.main(String[]) [Foo] EXACT_MATCH\n" + + "src/Foo.java void Main.main(String[]) [Foo] EXACT_MATCH"); + } finally { + deleteProject("P"); + } + } + /** + * @bug 297825: [search] Rename refactoring doesn't update enclosing type + * @test Search for references for the top level type Foo should report no match. "new _Foo.Bar.Foo()" refers to a different type. + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=297825" + */ + public void testBug297825c() throws CoreException { + try { + IJavaProject p = createJavaProject("P", new String[] { "src" }, + new String[] {"JCL_LIB"}, "bin"); + createFolder("/P/src/b297825"); + createFile("/P/src/b297825/_Foo.java", + "package b297825;\n" + + "public class _Foo {\n" + + " public static class Bar {\n" + + " public static class Foo {\n" + + " }\n" + + " }\n" + + "}" + ); + createFile("/P/src/b297825/Foo.java", + "package b297825;\n" + + "public class Foo extends _Foo {\n" + + "}" + ); + createFile("/P/src/b297825/Main.java", + "package b297825;\n" + + "class Main {\n" + + " public static void main(String[] args) {\n" + + " new _Foo.Bar.Foo();\n" + + " }\n" + + "}" + ); + waitUntilIndexesReady(); + IType type = getCompilationUnit("/P/src/b297825/Foo.java").getType("Foo"); + IJavaSearchScope scope = SearchEngine + .createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES); + + search(type, REFERENCES, scope, this.resultCollector); + + assertSearchResults(""); + } finally { + deleteProject("P"); + } + } + /** + * @bug 297825: [search] Rename refactoring doesn't update enclosing type + * @test Search for references for enclosing type's subclass should return a match. The inner type is parameterized. + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=297825" + */ + public void testBug297825d() throws CoreException { + try { + IJavaProject p = createJavaProject("P", new String[] { "src" }, + new String[] {"JCL_LIB"}, "bin"); + createFolder("/P/src/b297825"); + createFile("/P/src/b297825/_Foo.java", + "package b297825;\n" + + "public class _Foo {\n" + + " public static class Bar {\n" + + " }\n" + + "}" + ); + createFile("/P/src/b297825/Foo.java", + "package b297825;\n" + + "public class Foo extends _Foo {\n" + + "}\n" + ); + createFile("/P/src/b297825/Main.java", + "package b297825;\n" + + "public class Main {\n" + + " public static void main(String[] args) {\n" + + " new Foo.Bar();\n" + + " }\n" + + "}" + ); + waitUntilIndexesReady(); + IType type = getCompilationUnit("/P/src/b297825/Foo.java").getType("Foo"); + IJavaSearchScope scope = SearchEngine + .createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES); + + search(type, REFERENCES, scope, this.resultCollector); + + assertSearchResults("src/b297825/Main.java void b297825.Main.main(String[]) [Foo] EXACT_MATCH"); + } finally { + deleteProject("P"); + } + } + /** + * @bug 342393: Anonymous class' occurrence count is incorrect when two methods in a class have the same name. + * @test Search for Enumerators with anonymous types + * + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=342393" + */ + public void testBug342393() throws CoreException { + try { + IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "bin", "1.5"); + String content = "package b342393;\n" + "class Generic {\n" + + "enum A {\n" + "ONE {\n" + "A getSquare() {\n" + + "return ONE;\n" + "}\n" + "},\n" + "TWO {\n" + + "A getSquare() {\n" + "return TWO;\n" + "}\n" + "};\n" + + "abstract A getSquare();\n" + "}\n" + "}"; + createFolder("/P/b342393"); + createFile("/P/b342393/Generic.java", content); + IJavaSearchScope scope = SearchEngine. createJavaSearchScope( + new IJavaElement[] { project }, IJavaSearchScope.SOURCES); + search("getSquare", METHOD, DECLARATIONS, EXACT_RULE, scope, this.resultCollector); + assertSearchResults("b342393/Generic.java A b342393.Generic$A.ONE:#1.getSquare() [getSquare] EXACT_MATCH\n" + + "b342393/Generic.java A b342393.Generic$A.TWO:#1.getSquare() [getSquare] EXACT_MATCH\n" + + "b342393/Generic.java A b342393.Generic$A.getSquare() [getSquare] EXACT_MATCH"); + } finally { + deleteProject("P"); + } + } + + /** + * @bug 376673: DBCS4.2 Can not rename the class names when DBCS (Surrogate e.g. U+20B9F) is in it + * @test Search for DBCS type should report the match + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=376673" + */ + public void testBug376673a() throws CoreException { + try { + if ("macosx".equals(System.getProperty("osgi.os"))) { + System.out.println("testBug376673* may fail on macosx"); + return; + } + IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL17_LIB"}, "bin", "1.7"); + String content = "package pkg;\n" + + "class \uD842\uDF9F1 {}\n"; + createFolder("/P/pkg"); + try { + IFile file = createFile("/P/pkg/\uD842\uDF9F1.java", content, "UTF-8"); + file.setCharset("UTF-8", null); + } catch (UnsupportedEncodingException e) { + System.out.println("unsupported encoding"); + } + waitUntilIndexesReady(); + IJavaSearchScope scope = SearchEngine. createJavaSearchScope( + new IJavaElement[] { project }, IJavaSearchScope.SOURCES); + search("\uD842\uDF9F1", TYPE, DECLARATIONS, EXACT_RULE, scope, this.resultCollector); + assertSearchResults("pkg/\uD842\uDF9F1.java pkg.\uD842\uDF9F1 [\uD842\uDF9F1] EXACT_MATCH"); + } finally { + deleteProject("P"); + } + } + // Search for DBCS method should report the match + public void testBug376673b() throws CoreException { + try { + if ("macosx".equals(System.getProperty("osgi.os"))) { + return; + } + IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL17_LIB"}, "bin", "1.7"); + String content = "package pkg;\n" + + "class \uD842\uDF9F1 {" + + " public void \uD842\uDF9Fm() {}\n" + + "}\n"; + createFolder("/P/pkg"); + try { + IFile file = createFile("/P/pkg/\uD842\uDF9F1.java", content, "UTF-8"); + file.setCharset("UTF-8", null); + } catch (UnsupportedEncodingException e) { + System.out.println("unsupported encoding"); + } + waitUntilIndexesReady(); + IJavaSearchScope scope = SearchEngine. createJavaSearchScope( + new IJavaElement[] { project }, IJavaSearchScope.SOURCES); + search("\uD842\uDF9Fm", METHOD, DECLARATIONS, EXACT_RULE, scope, this.resultCollector); + assertSearchResults("pkg/\uD842\uDF9F1.java void pkg.\uD842\uDF9F1.\uD842\uDF9Fm() [\uD842\uDF9Fm] EXACT_MATCH"); + } finally { + deleteProject("P"); + } + } + // Search for DBCS constructor should report the match + public void testBug376673c() throws CoreException { + try { + if ("macosx".equals(System.getProperty("osgi.os"))) { + return; + } + IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL17_LIB"}, "bin", "1.7"); + String content = "package pkg;\n" + + "class \uD842\uDF9F1 {" + + " public \uD842\uDF9F1() {}\n" + + "}\n"; + createFolder("/P/pkg"); + try { + IFile file = createFile("/P/pkg/\uD842\uDF9F1.java", content, "UTF-8"); + file.setCharset("UTF-8", null); + } catch (UnsupportedEncodingException e) { + System.out.println("unsupported encoding"); + } + waitUntilIndexesReady(); + IJavaSearchScope scope = SearchEngine. createJavaSearchScope( + new IJavaElement[] { project }, IJavaSearchScope.SOURCES); + search("\uD842\uDF9F1", CONSTRUCTOR, DECLARATIONS, EXACT_RULE, scope, this.resultCollector); + assertSearchResults("pkg/\uD842\uDF9F1.java pkg.\uD842\uDF9F1() [\uD842\uDF9F1] EXACT_MATCH"); + } finally { + deleteProject("P"); + } + } + // Search for DBCS field should report the match + public void testBug376673d() throws CoreException { + try { + if ("macosx".equals(System.getProperty("osgi.os"))) { + return; + } + IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL17_LIB"}, "bin", "1.7"); + String content = "package pkg;\n" + + "class \uD842\uDF9F1 {" + + " public int \uD842\uDF9Ff;\n" + + "}\n"; + createFolder("/P/pkg"); + try { + IFile file = createFile("/P/pkg/\uD842\uDF9F1.java", content, "UTF-8"); + file.setCharset("UTF-8", null); + } catch (UnsupportedEncodingException e) { + System.out.println("unsupported encoding"); + } + waitUntilIndexesReady(); + IJavaSearchScope scope = SearchEngine. createJavaSearchScope( + new IJavaElement[] { project }, IJavaSearchScope.SOURCES); + search("\uD842\uDF9Ff", FIELD, DECLARATIONS, EXACT_RULE, scope, this.resultCollector); + assertSearchResults("pkg/\uD842\uDF9F1.java pkg.\uD842\uDF9F1.\uD842\uDF9Ff [\uD842\uDF9Ff] EXACT_MATCH"); + } finally { + deleteProject("P"); + } + } + // Search for DBCS package name from a jar also should report the match + public void testBug376673e() throws CoreException, IOException { + try { + if ("macosx".equals(System.getProperty("osgi.os"))) { + return; + } + String os = Platform.getOS(); + if (!Platform.OS_WIN32.equals(os)) { + // on Windows we have Windows-1252 as default, *nix should use UTF-8 + assertUTF8Encoding(); + } + IJavaProject p = createJavaProject("P", new String[] {}, new String[] { "/P/lib376673.jar", "JCL17_LIB" }, "", "1.7"); + IPath jarPath = p.getProject().getLocation().append("lib376673.jar"); + + org.eclipse.jdt.core.tests.util.Util.createJar( + new String[] { + "p\uD842\uDF9F/i\uD842\uDF9F/Test.java", + "package p\uD842\uDF9F.i\uD842\uDF9F;\n" + + "public class Test{}\n" }, + jarPath.toOSString(), + "1.7"); + refresh(p); + waitForAutoBuild(); + waitUntilIndexesReady(); + int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES; + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, mask); + search("Test", TYPE, DECLARATIONS, scope, this.resultCollector); + + try { + if (this.resultCollector.count == 0) { + System.out.println("Test " + getName() + " about to fail, listing extra debug info"); + System.out.println("LANG env variable: " + System.getenv("LANG")); + System.out.println("Listing markers of test project"); + IMarker[] markers = p.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE); + for (IMarker marker : markers) { + System.out.println(marker.getAttribute(IMarker.SEVERITY) + ":" + marker.getAttribute(IMarker.MESSAGE)); + } + System.out.println("Resolved classpath entries for test project:"); + for (IClasspathEntry e : p.getResolvedClasspath(false)) { + System.out.println(e); + } + System.out.println("All classpath entries for test project:"); + for (IClasspathEntry e : p.getResolvedClasspath(true)) { + System.out.println(e); + } + printJavaElements(p, System.out); + String jarFilePath = jarPath.toOSString(); + printZipContents(new File(jarFilePath), System.out); + } + } catch (Throwable t) { + System.out.println("Exception occurred while printing extra infos for test " + getName()); + t.printStackTrace(System.out); + } + + assertSearchResults("lib376673.jar p\uD842\uDF9F.i\uD842\uDF9F.Test [No source] EXACT_MATCH"); + } finally { + deleteProject("P"); + } + } + /** + * @bug 357547: [search] Search for method references is returning methods as overridden even if the superclass's method is only package-visible + * @test Search for a non-overridden method because of package visibility should not be found + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=357547" + */ + public void testBug357547a() throws CoreException { + IJavaProject project = null; + try + { + project = createJavaProject("P"); + createFolder("/P/p1"); + createFile("/P/p1/B.java", + "package p1;\n" + + "import p2.*;\n" + + "public class B extends A {\n" + + "long k(){\n" + + "return 0;\n" + + "}\n" + + "}\n"); + createFolder("/P/p2"); + createFile("/P/p2/A.java", + "package p2;\n" + + "public class A {\n" + + "long k(){\n" + + "return 0;\n" + + "}\n" + + "public long m(){\n"+ + "return new A().k();\n" + + "}\n"+ + "}\n"); + IType type = getCompilationUnit("/P/p1/B.java").getType("B"); + IMethod method = type.getMethod("k", new String[]{}); + search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults("Should not get any results", "", this.resultCollector); + } finally { + deleteProject(project); + } + } + + // search for the method name should also not return matches if not-overridden because of package-visible + public void testBug357547b() throws CoreException { + IJavaProject project = null; + try + { + project = createJavaProject("P"); + createFolder("/P/p1"); + createFile("/P/p1/B.java", + "package p1;\n" + + "import p2.*;\n" + + "public class B extends A {\n" + + "long k(){\n" + + "return 0;\n" + + "}\n" + + "}\n"); + createFolder("/P/p2"); + createFile("/P/p2/A.java", + "package p2;\n" + + "public class A {\n" + + "long k(){\n" + + "return 0;\n" + + "}\n" + + "public long m(){\n"+ + "return new A().k();\n" + + "}\n"+ + "}\n"); + waitUntilIndexesReady(); + // search + SearchPattern pattern = SearchPattern.createPattern("p*.B.k()", METHOD, REFERENCES , 0 ); + search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }), this.resultCollector); + assertSearchResults("Should not get any results", "", this.resultCollector); + } finally { + deleteProject(project); + } + } + + // search for the method name should return the match if same package + public void testBug357547c() throws CoreException { + IJavaProject project = null; + try + { + project = createJavaProject("P"); + createFolder("/P/p2"); + createFile("/P/p2/B.java", + "package p2;\n" + + "public class B extends A {\n" + + "long k(){\n" + + "return 0;\n" + + "}\n" + + "}\n"); + createFile("/P/p2/A.java", + "package p2;\n" + + "public class A {\n" + + "long k(){\n" + + "return 0;\n" + + "}\n" + + "public long m(){\n"+ + "return new A().k();\n" + + "}\n"+ + "}\n"); + waitUntilIndexesReady(); + // search + SearchPattern pattern = SearchPattern.createPattern("B.k()", METHOD, REFERENCES, EXACT_RULE); + search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }), this.resultCollector); + assertSearchResults("Wrong results", "p2/A.java long p2.A.m() [k()] EXACT_MATCH", this.resultCollector); + } finally { + deleteProject(project); + } + } + public void testBug357547d() throws CoreException { + IJavaProject project = null; + try + { + project = createJavaProject("P"); + createFolder("/P/p1"); + createFile("/P/p1/B.java", + "package p1;\n" + + "import p2.*;\n" + + "public class B extends A {\n" + + "long k(){\n" + + "return 0;\n" + + "}\n" + + "}\n"); + createFolder("/P/p2"); + createFile("/P/p2/A.java", + "package p2;\n" + + "public class A{ \n" + + "long k(){\n" + + "return 0;\n" + + "}\n" + + "public long m(){\n"+ + "return new A().k();\n" + + "}\n"+ + "}\n"); + createFile("/P/p2/B.java", + "package p2;\n" + + "public class B {\n" + + "}\n"); + waitUntilIndexesReady(); + // search + SearchPattern pattern = SearchPattern.createPattern("B.k()", METHOD, REFERENCES, EXACT_RULE); + search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }), this.resultCollector); + assertSearchResults("Should not get any results", "", this.resultCollector); + } finally { + deleteProject(project); + } + } + // search for the method name should also not return matches if not-overridden because of package-visible + // even if they are in jars + public void testBug357547e() throws CoreException, IOException { + IJavaProject project = null; + try + { + project = createJavaProject("P", new String[] {""}, new String[] { "/P/lib357547.jar", "JCL15_LIB" }, "", "1.5"); + org.eclipse.jdt.core.tests.util.Util.createJar(new String[] { + "p2/A.java", + "package p2;\n" + + "public class A{}\n" }, + project.getProject().getLocation().append("libStuff.jar").toOSString(), "1.5"); + + org.eclipse.jdt.core.tests.util.Util.createJar( + new String[] { + "p1/B.java", + "package p1;\n"+ + "import p2.*;\n"+ + "public class B extends A {\n" + + "long k(){\n" + + "return 0;\n" + + "}\n" + + "}\n"}, + null, + project.getProject().getLocation().append("lib357547.jar").toOSString(), + new String[] { project.getProject().getLocation().append("libStuff.jar").toOSString() }, + "1.5"); + refresh(project); + createFolder("/P/p2"); + createFile("/P/p2/A.java", + "package p2;\n" + + "public class A {\n" + + "long k(){\n" + + "return 0;\n" + + "}\n" + + "public long m(){\n"+ + "return new A().k();\n" + + "}\n"+ + "}\n"); + waitUntilIndexesReady(); + // search + SearchPattern pattern = SearchPattern.createPattern("B.k()", METHOD, REFERENCES, EXACT_RULE); + search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES), this.resultCollector); + assertSearchResults("Wrong results", "", this.resultCollector); + } finally { + deleteProject(project); + } + } + // search for the method name should also not return matches if not-overridden because of package-visible + // even if they are in jars + public void testBug357547f() throws CoreException, IOException { + IJavaProject project = null; + try + { + project = createJavaProject("P", new String[] {""}, new String[] { "/P/lib357547.jar", "JCL15_LIB" }, "", "1.5"); + org.eclipse.jdt.core.tests.util.Util.createJar(new String[] { + "p2/A.java", + "package p2;\n" + + "public class A{}\n" }, + project.getProject().getLocation().append("libStuff.jar").toOSString(), "1.5"); + + org.eclipse.jdt.core.tests.util.Util.createJar( + new String[] { + "p2/B.java", + "package p2;\n" + + "import p2.*;\n" + + "public class B extends A {\n" + + "long k(){\n" + + "return 0;\n" + + "}\n" + + "}\n"}, + null, + project.getProject().getLocation().append("lib357547.jar").toOSString(), + new String[] { project.getProject().getLocation().append("libStuff.jar").toOSString() }, + "1.5"); + refresh(project); + createFolder("/P/p2"); + createFile("/P/p2/A.java", + "package p2;\n" + + "public class A {\n" + + "long k(){\n" + + "return 0;\n" + + "}\n" + + "public long m(){\n"+ + "return new A().k();\n" + + "}\n"+ + "}\n"); + waitUntilIndexesReady(); + // search + SearchPattern pattern = SearchPattern.createPattern("B.k()", METHOD, REFERENCES, EXACT_RULE); + search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES), this.resultCollector); + assertSearchResults("Wrong results", "p2/A.java long p2.A.m() [k()] EXACT_MATCH", this.resultCollector); + } finally { + deleteProject(project); + } + } + // search for declarations also should take care of default + public void testBug357547g() throws CoreException { + IJavaProject project = null; + try + { + project = createJavaProject("P"); + createFolder("/P/p1"); + createFile("/P/p1/B.java", + "package p1;\n" + + "import p2.*;\n" + + "public class B extends A {\n" + + "long k(int a){\n" + + "return 0;\n" + + "}\n" + + "}\n"); + createFile("/P/p1/C.java", + "package p1;\n" + + "public class C extends B {\n" + + "long k(int a){\n" + + "return 0;\n" + + "}\n" + + "}\n"); + createFolder("/P/p2"); + createFile("/P/p2/A.java", + "package p2;\n" + + "public class A{ \n" + + "long k(int a){\n" + + "return 0;\n" + + "}\n" + + "public long m(){\n"+ + "return new A().k(0);\n" + + "}\n"+ + "}\n"); + createFile("/P/p2/B.java", + "package p2;\n" + + "public class B {\n" + + "}\n"); + waitUntilIndexesReady(); + // search + SearchPattern pattern = SearchPattern.createPattern("A.k(int)", METHOD, DECLARATIONS, EXACT_RULE); + search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }), this.resultCollector); + assertSearchResults("Wrong results", "p2/A.java long p2.A.k(int) [k] EXACT_MATCH", this.resultCollector); + } finally { + deleteProject(project); + } + } + public void testBug378390() throws CoreException { + IJavaProject project = null; + try + { + project = createJavaProject("P"); + createFolder("/P/p1"); + createFile("/P/p1/B.java", + "package p1;\n" + + "import p2.*;\n" + + "public class B extends A {\n" + + "long k(){\n" + + "return 0;\n" + + "}\n" + + "}\n"); + createFolder("/P/p2"); + createFile("/P/p2/A.java", + "package p2;\n" + + "public class A {\n" + + "class B extends A {\n" + + "long k(){\n" + + "return 0;\n" + + "}\n" + + "}\n" + + "long k(){\n" + + "return 0;\n" + + "}\n" + + "public long m(){\n"+ + "return new A().k();\n" + + "}\n"+ + "}\n"); + IType type = getCompilationUnit("/P/p2/A.java").getType("A"); + type = type.getTypes()[0]; + IMethod method = type.getMethod("k", new String[]{}); + search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults("Wrong results", "p2/A.java long p2.A.m() [k()] EXACT_MATCH", this.resultCollector); + } finally { + deleteProject(project); + } + } + /** + * @bug 375971: [search] Not finding method references with generics + * @test TODO + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=375971" + */ + public void testBug375971a() throws CoreException { + try { + createJavaProject("P"); + createFile("/P/InterfaceI.java", + "public interface InterfaceI {\n"+ + " public void addListener();\n"+ + "}\n"); + createFile("/P/ClassA.java", + "public class ClassA implements InterfaceI{\n"+ + " public void addListener() {\n" + + "}\n" + + "}\n"); + createFile("/P/ClassB.java", + "public class ClassB extends ClassA{\n"+ + " public void doSomething() {" + + " addListener();\n"+ + "}\n" + + "}\n"); + waitUntilIndexesReady(); + // search + IType type = getCompilationUnit("/P/InterfaceI.java").getType("InterfaceI"); + IMethod method = type.getMethod("addListener", new String[]{}); + this.resultCollector.showRule(); + search(method, REFERENCES, ERASURE_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults("ClassB.java void ClassB.doSomething() [addListener()] ERASURE_MATCH"); + } finally { + deleteProject("P"); + } + } + public void testBug375971b() throws CoreException { + try { + createJavaProject("P"); + createFile("/P/InterfaceI.java", + "public interface InterfaceI {\n"+ + " public void addListener();\n"+ + "}\n"); + createFile("/P/ClassA.java", + "public class ClassA {\n"+ + " public void addListener() {\n" + + "}\n" + + "}\n"); + createFile("/P/ClassB.java", + "public class ClassB extends ClassA implements InterfaceI{\n"+ + " public void doSomething() {" + + " addListener();\n"+ + "}\n" + + "}\n"); + waitUntilIndexesReady(); + // search + IType type = getCompilationUnit("/P/InterfaceI.java").getType("InterfaceI"); + IMethod method = type.getMethod("addListener", new String[]{}); + this.resultCollector.showRule(); + search(method, REFERENCES, ERASURE_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults("ClassB.java void ClassB.doSomething() [addListener()] ERASURE_MATCH"); + } finally { + deleteProject("P"); + } + } + public void testBug375971c() throws CoreException { + try { + createJavaProject("P"); + createFile("/P/InterfaceI.java", + "public interface InterfaceI {\n"+ + " public void addListener();\n"+ + "}\n"); + createFile("/P/ClassA.java", + "public class ClassA {\n"+ + " public void addListener() {\n" + + "}\n" + + "}\n"); + createFile("/P/ClassB.java", + "public class ClassB extends ClassA implements InterfaceI{\n"+ + " public void doSomething() {" + + " addListener();\n"+ + "}\n" + + "}\n"); + waitUntilIndexesReady(); + // search + IType type = getCompilationUnit("/P/ClassA.java").getType("ClassA"); + IMethod method = type.getMethod("addListener", new String[]{}); + this.resultCollector.showRule(); + search(method, REFERENCES, ERASURE_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults("ClassB.java void ClassB.doSomething() [addListener()] ERASURE_MATCH"); + } finally { + deleteProject("P"); + } + } + public void testBug375971d() throws CoreException { + try { + createJavaProject("P"); + createFile("/P/InterfaceI.java", + "public interface InterfaceI {\n"+ + " public void addListener();\n"+ + "}\n"); + createFile("/P/ClassA.java", + "public class ClassA implements InterfaceI{\n"+ + " public void addListener() {\n" + + "}\n" + + "}\n"); + createFile("/P/ClassB.java", + "public class ClassB {\n"+ + " public void doSomething(ClassA a) {" + + " a.addListener();\n"+ + "}\n" + + "}\n"); + waitUntilIndexesReady(); + // search + IType type = getCompilationUnit("/P/InterfaceI.java").getType("InterfaceI"); + IMethod method = type.getMethod("addListener", new String[]{}); + this.resultCollector.showRule(); + search(method, REFERENCES, ERASURE_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults("ClassB.java void ClassB.doSomething(ClassA) [addListener()] ERASURE_RAW_MATCH"); + } finally { + deleteProject("P"); + } + } + public void testBug375971e() throws CoreException { + try { + createJavaProject("P"); + createFile("/P/InterfaceI.java", + "public interface InterfaceI {\n"+ + " public void addListener();\n"+ + "}\n"); + createFile("/P/ClassA.java", + "public class ClassA implements InterfaceI {\n"+ + " public void addListener() {\n" + + "}\n" + + "}\n"); + createFile("/P/ClassB.java", + "public class ClassB implements InterfaceI {\n"+ + " public void doSomething() {" + + " addListener();\n"+ + "}\n" + + "}\n"); + createFile("/P/ClassC.java", + "public class ClassC extends ClassA {\n"+ + " public void doSomething() {" + + " addListener();\n"+ + "}\n" + + "}\n"); + waitUntilIndexesReady(); + // search + ICompilationUnit unit = getCompilationUnit("/P/ClassB.java"); + IMethod method = selectMethod(unit, "addListener"); + this.resultCollector.showRule(); + search(method, REFERENCES, ERASURE_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults("ClassB.java void ClassB.doSomething() [addListener()] EXACT_MATCH\n" + + "ClassC.java void ClassC.doSomething() [addListener()] ERASURE_MATCH"); + } finally { + deleteProject("P"); + } + } + public void testBug375971f() throws CoreException { + try { + createJavaProject("P"); + createFile("/P/InterfaceI.java", + "public interface InterfaceI {\n"+ + " public void addListener();\n"+ + "}\n"); + createFile("/P/ClassA.java", + "public class ClassA implements InterfaceI{\n"+ + " public void addListener() {\n" + + "}\n" + + "}\n"); + createFile("/P/ClassB.java", + "public class ClassB extends ClassA{\n"+ + " public void doSomething() {" + + " addListener();\n"+ + "}\n" + + "}\n"); + waitUntilIndexesReady(); + // search + IType type = getCompilationUnit("/P/InterfaceI.java").getType("InterfaceI"); + IMethod method = type.getMethod("addListener", new String[]{}); + this.resultCollector.showRule(); + search(method, REFERENCES, ERASURE_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults("ClassB.java void ClassB.doSomething() [addListener()] EXACT_MATCH"); + } finally { + deleteProject("P"); + } + } + public void testBug375971g() throws CoreException { + try { + createJavaProject("P"); + createFile("/P/InterfaceI.java", + "public interface InterfaceI {\n"+ + " public void addListener();\n"+ + "}\n"); + createFile("/P/ClassA.java", + "public class ClassA implements InterfaceI{\n"+ + " public void addListener() {\n" + + "}\n" + + "}\n"); + createFile("/P/ClassB.java", + "public class ClassB extends ClassA{\n"+ + " public void doSomething() {" + + " addListener();\n"+ + "}\n" + + "}\n"); + waitUntilIndexesReady(); + // search + IType type = getCompilationUnit("/P/InterfaceI.java").getType("InterfaceI"); + IMethod method = type.getMethod("addListener", new String[]{}); + this.resultCollector.showRule(); + search(method, REFERENCES, ERASURE_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults("ClassB.java void ClassB.doSomething() [addListener()] EXACT_MATCH"); + } finally { + deleteProject("P"); + } + } + public void testBug375971h() throws CoreException { + try { + createJavaProject("P"); + createFile("/P/InterfaceI.java", + "public interface InterfaceI {\n"+ + " public void addListener();\n"+ + "}\n"); + createFile("/P/ClassA.java", + "public class ClassA implements InterfaceI{\n"+ + " public void addListener() {\n" + + "}\n" + + "}\n"); + createFile("/P/ClassB.java", + "public class ClassB extends ClassA{\n"+ + " public void doSomething(InterfaceI i) {" + + " i.addListener();\n"+ + "}\n" + + "}\n"); + waitUntilIndexesReady(); + // search + IType type = getCompilationUnit("/P/ClassA.java").getType("ClassA"); + IMethod method = type.getMethod("addListener", new String[]{}); + this.resultCollector.showRule(); + search(method, REFERENCES, ERASURE_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults("ClassB.java void ClassB.doSomething(InterfaceI) [addListener()] EXACT_MATCH"); + } finally { + deleteProject("P"); + } + } + public void testBug375971i() throws CoreException { + try { + createJavaProject("P"); + createFile("/P/InterfaceI.java", + "public interface InterfaceI {\n"+ + " public void addListener(K k);\n"+ + "}\n"); + createFile("/P/ClassA.java", + "public class ClassA implements InterfaceI{\n"+ + "public void addListener(K k) {\n" + + "}\n" + + "}\n"); + createFile("/P/ClassB.java", + "public class ClassB extends ClassA{\n"+ + " public void doSomething(K k) {" + + " addListener(k);\n"+ + "}\n" + + "}\n"); + waitUntilIndexesReady(); + // search + IType type = getCompilationUnit("/P/InterfaceI.java").getType("InterfaceI"); + IMethod method = type.getMethods()[0]; + this.resultCollector.showRule(); + search(method, REFERENCES, ERASURE_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults("ClassB.java void ClassB.doSomething(K) [addListener(k)] ERASURE_MATCH"); + } finally { + deleteProject("P"); + } + } + // search for constructor declarations in javadoc + public void testBug381567a() throws CoreException { + try { + IJavaProject p = createJavaProject("P", new String[] { "src" }, + new String[] {"JCL_LIB"}, "bin"); + createFolder("/P/src/b381567"); + createFile("/P/src/b381567/A.java", + "package b381567;\n" + + "/**\n" + + "* {@link B#equals(java.lang.Object)}\n" + + "*/\n" + + "public class A {\n" + + " A() {}\n" + + "}"); + createFile("/P/src/b381567/B.java", + "package b381567;\n" + + "public class B {\n" + + "}"); + waitUntilIndexesReady(); + IJavaSearchScope scope = SearchEngine + .createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES); + SearchPattern pattern = SearchPattern.createPattern("*", CONSTRUCTOR, DECLARATIONS, SearchPattern.R_PATTERN_MATCH); + this.resultCollector.showInsideDoc(); + + search(pattern, scope, this.resultCollector); + + assertSearchResults("src/b381567/A.java b381567.A() [A] EXACT_MATCH OUTSIDE_JAVADOC"); + } finally { + deleteProject("P"); + } + } + // search for all constructor occurrences (declarations and references) in javadoc + public void testBug381567b() throws CoreException { + try { + IJavaProject p = createJavaProject("P", new String[] { "src" }, + new String[] {"JCL_LIB"}, "bin"); + createFolder("/P/src/b381567"); + createFile("/P/src/b381567/A.java", + "package b381567;\n" + + "class A {\n" + + " A(Exception ex) {}\n" + + " class B { \n" + + " /**\n" + + " * Link {@link #A(Exception)} OK\n" + + " */\n" + + " public B(String str) {}\n" + + " }\n" + + "}" + ); + waitUntilIndexesReady(); + IMethod[] methods = getCompilationUnit("/P/src/b381567/A.java") + .getType("A").getMethods(); + assertEquals("Invalid number of methods", 1, methods.length); + assertTrue(methods[0].isConstructor()); + IJavaSearchScope scope = SearchEngine + .createJavaSearchScope(new IJavaElement[] { p }); + this.resultCollector.showInsideDoc(); + + search(methods[0], ALL_OCCURRENCES, scope); + + assertSearchResults("src/b381567/A.java b381567.A(Exception) [A] EXACT_MATCH OUTSIDE_JAVADOC\n" + + "src/b381567/A.java b381567.A$B(String) [A(Exception)] EXACT_MATCH INSIDE_JAVADOC"); + } finally { + deleteProject("P"); + } + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=382778, Call hierarchy missing valid callers probably because java search marks exact matches as potential + public void testBug382778() throws CoreException { + try { + IJavaProject p = createJavaProject("P", new String[] { "src" }, + new String[] {"JCL_LIB"}, "bin"); + createFolder("/P/src/b382778"); + createFile("/P/src/b382778/Impl2.java", + "package b382778;\n" + + "public class Impl2 implements PublicInterface2 {\n" + + " private final String name;\n" + + " public Impl2(String name) {\n" + + " this.name = name;\n" + + " }\n" + + " public String getName() {\n" + + " return name;\n" + + " }\n" + + "}\n" + ); + createFile("/P/src/b382778/Main.java", + "package b382778;\n" + + "public class Main {\n" + + " public static void main(String[] args) {\n" + + " broken();\n" + + " ok();\n" + + " }\n" + + " private static void broken() {\n" + + " PublicInterface2 impl2 = new Impl2(\"Name Broken\");\n" + + " Static.printIt(impl2.getName());\n" + + " }\n" + + " private static void ok() {\n" + + " PublicInterface2 impl2 = new Impl2(\"Name OK\");\n" + + " String name = impl2.getName();\n" + + " Static.printIt(name);\n" + + " }\n" + + "}\n" + ); + createFile("/P/src/b382778/MainBroken.java", + "package b382778;\n" + + "public class MainBroken {\n" + + " public static void main(String[] args) {\n" + + " PublicInterface2 impl2 = new Impl2(\"Name Broken\");\n" + + " Static.printIt(impl2.getName());\n" + + " }\n" + + "}\n" + ); + createFile("/P/src/b382778/MainOK.java", + "package b382778;\n" + + "public class MainOK {\n" + + " public static void main(String[] args) {\n" + + " PublicInterface2 impl2 = new Impl2(\"Name OK\");\n" + + " String name = impl2.getName();\n" + + " Static.printIt(name);\n" + + " }\n" + + "}\n" + ); + createFile("/P/src/b382778/PublicInterface1.java", + "package b382778;\n" + + "public interface PublicInterface1 extends PackageInterface1Getters {\n" + + "}\n" + + "/* package */interface PackageInterface1Getters {\n" + + "String getName();\n" + + "}" + ); + createFile("/P/src/b382778/PublicInterface2.java", + "package b382778;\n" + + "public interface PublicInterface2 extends PackageInterface2Getters {\n" + + "}\n" + + "/* package */interface PackageInterface2Getters extends PackageInterface1Getters {\n" + + "}\n" + ); + createFile("/P/src/b382778/Static.java", + "package b382778;\n" + + "public class Static {\n" + + "public static void printIt(String it) {\n" + + "System.out.println(it);\n" + + "}\n" + + "}" + ); + waitUntilIndexesReady(); + ICompilationUnit unit = getCompilationUnit("/P/src/b382778/Static.java"); + IMethod method = unit.getType("Static").getMethod("printIt", + new String[] { "QString;" }); + IJavaSearchScope scope = SearchEngine + .createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES); + + search(method, REFERENCES, scope, this.resultCollector); + + assertSearchResults("src/b382778/Main.java void b382778.Main.broken() [printIt(impl2.getName())] EXACT_MATCH\n" + + "src/b382778/Main.java void b382778.Main.ok() [printIt(name)] EXACT_MATCH\n" + + "src/b382778/MainBroken.java void b382778.MainBroken.main(String[]) [printIt(impl2.getName())] EXACT_MATCH\n" + + "src/b382778/MainOK.java void b382778.MainOK.main(String[]) [printIt(name)] EXACT_MATCH"); + } finally { + deleteProject("P"); + } + } + public void testBug383315a() throws CoreException { + try { + IJavaProject p = createJavaProject("P", new String[] {}, new String[] { "JCL15_LIB" }, "", "1.5"); + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES); + + search("java.lang.Object.hashCode()", METHOD, ALL_OCCURRENCES, scope, this.resultCollector); + + assertSearchResults(""); // an NPE was thrown without the fix + } finally { + deleteProject("P"); + } + } + public void testBug383315b() throws CoreException { + try { + IJavaProject p = createJavaProject("P"); + createFolder("/P/pkg"); + createFile("/P/pkg/A.java", + "package pkg;\n"+ + "public class A {\n"+ + " void a() {\n"+ + " }\n"+ + "}"); + createFile("/P/pkg/B.java", + "package pkg;\n"+ + "public class B extends A {\n"+ + " void a() {\n"+ + " }\n"+ + "}"); + createFile("/P/pkg/C.java", + "package pkg;\n"+ + "public class C extends B {\n"+ + " void a() {\n"+ + " }\n"+ + "}"); + createFile("/P/pkg/D.java", + "package pkg;\n"+ + "public class D extends C {\n"+ + " void a() {\n"+ + " }\n"+ + " void d() {\n"+ + " new A().a();\n"+ + " }\n"+ + "}"); + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES); + + search("C.a()", METHOD, REFERENCES, scope, this.resultCollector); + + assertSearchResults("pkg/D.java void pkg.D.d() [a()] EXACT_MATCH"); + } finally { + deleteProject("P"); + } + } + public void testBug395348() throws CoreException { + try { + IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); + createFile("/P/X.java", + "public class X {\n"+ + " static void f() {\n" + + " new Y() {\n"+ + " public int compare(C2 o1) {\n" + + " return 0;\n" + + " }\n" + + " };\n"+ + " }\n" + + "}\n" + + "interface Y {\n" + + " public abstract int compare(T o1);\n" + + "}\n" + + "class C2 {}\n" + ); + IMethod method = selectMethod(getCompilationUnit("/P/X.java"), "compare", 0); + MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(method, DECLARATIONS|IGNORE_DECLARING_TYPE|IGNORE_RETURN_TYPE, EQUIVALENT_RULE|EXACT_RULE); + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.SOURCES); + search(pattern, scope, this.resultCollector); + assertSearchResults("X.java int void X.f():#1.compare(C2) [compare] EXACT_MATCH\n" + + "X.java int Y.compare(T) [compare] EXACT_MATCH"); // an NPE was thrown without the fix + } finally { + deleteProject("P"); + } + } + + public void testBug401272() throws CoreException, IOException { + boolean indexState = isIndexDisabledForTest(); + // the strategy of this test was outlined in https://bugs.eclipse.org/bugs/show_bug.cgi?id=401272#c16 + try { + IJavaProject p = createJavaProject("P", new String[] { "src" }, new String[] { "JCL15_LIB", "/P/libStuff.jar" }, "bin", "1.5"); + + org.eclipse.jdt.core.tests.util.Util.createJar( + new String[] { + // this class must be our possibleMatch #401 + // it must be binary to trigger the ClassFileMatchLocator + // the match must be impossible-due-to-mismatching-type-variables to trigger matchLocator.getMethodBinding(this.pattern); + "p2/A.java", + "package p2;\n" + + "public class A {\n" + + " public int test(E b) { return 1; }\n" + + " void bar() {\n" + + " test(null);\n" + + " }\n" + + "}\n", + // this class contains the method we search for, possibleMatch #402 + // (must be > 401 possibleMatches to trigger environment cleanup) + "p2/B.java", + "package p2;\n" + + "public class B {\n" + + " public int test(T t) {\n" + + " return 0;\n" + + " }\n" + + "}\n" + }, + p.getProject().getLocation().append("libStuff.jar").toOSString(), "1.5"); + refresh(p); + + createFolder("/P/src/pkg"); + + this.indexDisabledForTest = true; + // 400 matches, which populate MatchLocator.unitScope + // all 400 matches are processed in one go of MatchLocator.locateMatches(JavaProject, PossibleMatch[], int, int) + // next round will call nameEnvironment.cleanup() but reuse MatchLocator.unitScope ==> BOOM + for (int i = 0; i < 400; i++) { + createFile("/P/src/pkg/Bug"+i+".java", + "package pkg;\n"+ + "public class Bug"+i+" {\n"+ + " String[] test(p2.B b) {\n" + + " return b.test(\"S\");\n" + + " }\n" + + "}"); + } + waitUntilIndexesReady(); + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, + IJavaSearchScope.SOURCES|IJavaSearchScope.SYSTEM_LIBRARIES|IJavaSearchScope.APPLICATION_LIBRARIES); + + IMethod method = p.findType("p2.B").getMethods()[1]; + search(method, METHOD, ALL_OCCURRENCES, scope, this.resultCollector); + + assertSearchResults("libStuff.jar int p2.B.test(T) [No source] EXACT_MATCH"); // an NPE was thrown without the fix + } finally { + deleteProject("P"); + this.indexDisabledForTest = indexState; + } + } + /** + * @bug 423409: [search] Search shows references to fields as potential matches + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=423409" + */ + public void testBug423409() throws CoreException, JavaModelException { + try { + createJavaProject("P", new String[] { "src" }, + new String[] {"JCL_LIB"}, "bin"); + createFolder("/P/src/com/test"); + createFile("/P/src/com/test/Test2.java", + "package com.test;\n" + + "\n" + + "class Test2 {\n" + + " public static final FI fi/*here*/ = null; // find references of 'fi' via Ctrl+Shift+G\n" + + " \n" + + " {\n" + + " fun1(fi);\n" + + " }\n" + + " \n" + + " private FI fun1(FI x) {\n" + + " System.out.println(fi);\n" + + " return fi;\n" + + " }\n" + + "}\n" ); + createFile("/P/src/com/test/Test1.java", + "package com.test;\n" + + "\n" + + "class Test1 {\n" + + " public static final FI fi = null;\n" + + "}\n" ); + createFile("/P/src/com/test/T.java", + "package com.test;\n" + + "\n" + + "interface FI {\n" + + " int foo(int x);\n" + + "}\n"); + waitUntilIndexesReady(); + IType type = getCompilationUnit("/P/src/com/test/Test2.java").getType("Test2"); + IJavaElement field = type.getField("fi"); + search(field, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + + assertSearchResults( + "src/com/test/Test2.java com.test.Test2.{} [fi] EXACT_MATCH\n" + + "src/com/test/Test2.java FI com.test.Test2.fun1(FI) [fi] EXACT_MATCH\n" + + "src/com/test/Test2.java FI com.test.Test2.fun1(FI) [fi] EXACT_MATCH"); + } finally { + deleteProject("P"); + } + } + public void testBug381392() throws CoreException { + IJavaProject egit = null; + IJavaProject jgit = null; + try { + jgit = createJavaProject("jgit", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); + createFolder("/jgit/base"); + createFile("/jgit/base/AbstractPlotRenderer.java", + "package base;\n" + + "public abstract class AbstractPlotRenderer {\n"+ + " protected abstract TColor laneColor(TLane myLane);\n"+ + "\n"+ + " @SuppressWarnings(\"unused\")\n"+ + " protected void paintCommit(final PlotCommit commit) {\n"+ + " final TLane myLane = commit.getLane();\n"+ + " final TColor myColor = laneColor(myLane);\n"+ + " }\n"+ + "}\n"); + createFile("/jgit/base/PlotCommit.java", + "package base;\n"+ + "public class PlotCommit {\n"+ + " public L getLane() {\n"+ + " return null;\n"+ + " }\n"+ + "}"); + createFile("/jgit/base/PlotLane.java", + "package base;\n"+ + "public class PlotLane {\n"+ + "}"); + egit = createJavaProject("egit", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5"); + createFolder("/egit/bug"); + createFile("/egit/bug/SWTPlotLane.java", + "package bug;\n" + + "import base.PlotLane;\n" + + "public class SWTPlotLane extends PlotLane {}"); + createFile("/egit/bug/SWTPlotRenderer.java", + "package bug;\n" + + "import base.AbstractPlotRenderer;\n" + + "class SWTPlotRenderer extends AbstractPlotRenderer {\n" + + " @Override\n" + + " protected Integer laneColor(SWTPlotLane myLane) {\n" + + " return 1;\n" + + " }\n" + + "}"); + addClasspathEntry(egit, JavaCore.newProjectEntry(jgit.getPath())); + + // search + IType type = getCompilationUnit("/egit/bug/SWTPlotRenderer.java").getType("SWTPlotRenderer"); + IMethod method = type.getMethods()[0]; + search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults("base/AbstractPlotRenderer.java void base.AbstractPlotRenderer.paintCommit(PlotCommit) [laneColor(myLane)] EXACT_MATCH"); + } finally { + if (jgit != null) deleteProject(jgit); + if (egit != null) deleteProject(egit); + } + } + public void testBug469965_0001() throws CoreException { + try { + + IJavaProject project = createJavaProject("P", new String[] {"src"}, new String[] { "/P/lib469965.jar", "JCL18_LIB" }, "bin", "1.8"); + String libsource = "package f3;\n" + + "public class X {\n" + + " void foo() {\n" + + " final Y y = new Y();\n" + + " new X() {\n" + + " void goo() { y.bar();}\n" + + " };\n" + + " new X() {\n" + + " void goo() { y.bar();}\n" + + " };\n" + + " }\n" + + " void goo() {\n" + + " final Y y = new Y();\n" + + " new X() {\n" + + " void goo() { y.bar();}\n" + + " };\n" + + " new X() {\n" + + " void goo() { y.bar();}\n" + + " };\n" + + " }\n" + + "}\n" + + "class Y {\n" + + " void bar() {} \n" + + "}\n"; + String jarFileName = "lib469965.jar"; + String srcZipName = "lib469965.src.zip"; + createLibrary(project, jarFileName, srcZipName, new String[] {"f3/X.java",libsource}, new String[0], JavaCore.VERSION_1_5); + IFile srcZip=(IFile) project.getProject().findMember(srcZipName); + IFile jar = (IFile) project.getProject().findMember(jarFileName); + project.getPackageFragmentRoot(jar).attachSource(srcZip.getFullPath(), null, null); + waitUntilIndexesReady(); + + IType type = getClassFile("P", jarFileName, "f3", "Y.class").getType(); + IMethod method = type.getMethods()[1]; + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES); + search(method, REFERENCES, scope); + assertSearchResults( + "lib469965.jar void f3..goo() EXACT_MATCH\n" + + "lib469965.jar void f3..goo() EXACT_MATCH\n" + + "lib469965.jar void f3..goo() EXACT_MATCH\n" + + "lib469965.jar void f3..goo() EXACT_MATCH"); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + finally { + deleteProject("P"); + } + } + public void testBug469965_0002() throws CoreException { + try { + + IJavaProject project = createJavaProject("P", new String[] {"src"}, new String[] { "/P/lib469965.jar", "JCL18_LIB" }, "bin", "1.8"); + String libsource = "package f3;\n" + + "public class X {\n" + + " void foo() {\n" + + " final Y y = new Y();\n" + + " new X() {\n" + + " void goo() { y.bar();}\n" + + " };\n" + + " new X() {\n" + + " void goo() { y.bar();}\n" + + " };\n" + + " }\n" + + " void goo() {\n" + + " final Y y = new Y();\n" + + " new X() {\n" + + " void goo() {\n" + + " new X() {\n" + + " void goo() { y.bar();}\n" + + " };\n" + + " y.bar();\n" + + " }\n" + + " };\n" + + " new X() {\n" + + " void goo() { y.bar();}\n" + + " };\n" + + " }\n" + + "}\n" + + "class Y {\n" + + " void bar() {} \n" + + "}\n"; + String jarFileName = "lib469965.jar"; + String srcZipName = "lib469965.src.zip"; + createLibrary(project, jarFileName, srcZipName, new String[] {"f3/X.java",libsource}, new String[0], JavaCore.VERSION_1_5); + IFile srcZip=(IFile) project.getProject().findMember(srcZipName); + IFile jar = (IFile) project.getProject().findMember(jarFileName); + project.getPackageFragmentRoot(jar).attachSource(srcZip.getFullPath(), null, null); + waitUntilIndexesReady(); + + IType type = getClassFile("P", jarFileName, "f3", "Y.class").getType(); + IMethod method = type.getMethods()[1]; + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES); + search(method, REFERENCES, scope); + assertSearchResults( + "lib469965.jar void f3..goo() EXACT_MATCH\n" + + "lib469965.jar void f3..goo() EXACT_MATCH\n" + + "lib469965.jar void f3..goo() EXACT_MATCH\n" + + "lib469965.jar void f3..goo() EXACT_MATCH\n" + + "lib469965.jar void f3..goo() EXACT_MATCH"); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + finally { + deleteProject("P"); + } + } + + public void testBug473921() throws Exception { + try { + IJavaProject p = this.createJavaProject( + "P", + new String[] {}, + new String[] { "/P/lib473921.jar", "JCL17_LIB" }, + new String[][] {{ "p/*" }, { }}, + new String[][] {{ "**/*" }, { }}, + null/*no project*/, + null/*no inclusion pattern*/, + null/*no exclusion pattern*/, + null/*no exported project*/, + "", + null/*no source outputs*/, + null/*no inclusion pattern*/, + null/*no exclusion pattern*/, + "1.7" + ); + org.eclipse.jdt.core.tests.util.Util.createJar( + new String[] { + "p/Enclosing.java", + "package p;\n" + + "public class Enclosing { enum Nested { A, B; class Matryoshka { } } }\n", + "classified/CEnclosing.java", + "package classified;\n" + + "public class CEnclosing { interface CNested { class CMatryoshka { } } }\n" + }, + p.getProject().getLocation().append("lib473921.jar").toOSString(), + "1.7"); + refresh(p); + + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }); + class Collector extends TypeNameMatchRequestor { + List matches = new ArrayList<>(); + @Override + public void acceptTypeNameMatch(TypeNameMatch match) { + this.matches.add(match); + } + } + Collector collector = new Collector(); + new SearchEngine().searchAllTypeNames( + null, + new char[][] { "Nested".toCharArray(), "Enclosing".toCharArray(), "Matryoshka".toCharArray() }, + scope, + collector, + IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, + null); + assertEquals(3, collector.matches.size()); + assertEquals(IAccessRule.K_ACCESSIBLE, collector.matches.get(0).getAccessibility()); + assertEquals(IAccessRule.K_ACCESSIBLE, collector.matches.get(1).getAccessibility()); // bug 482309 + assertEquals(IAccessRule.K_ACCESSIBLE, collector.matches.get(2).getAccessibility()); // bug 482309 (double-nested type) + + collector = new Collector(); + new SearchEngine().searchAllTypeNames( + null, + new char[][] { "CNested".toCharArray(), "CEnclosing".toCharArray(), "CMatryoshka".toCharArray() }, + scope, + collector, + IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, + null); + assertEquals(3, collector.matches.size()); + assertEquals(IAccessRule.K_NON_ACCESSIBLE, collector.matches.get(0).getAccessibility()); + assertEquals(IAccessRule.K_NON_ACCESSIBLE, collector.matches.get(1).getAccessibility()); // bug 482309 + assertEquals(IAccessRule.K_NON_ACCESSIBLE, collector.matches.get(2).getAccessibility()); // bug 482309 (double-nested type) + } finally { + deleteProject("P"); + } + } + public void testBug478042_0001() throws Exception { + IJavaProject project = null; + try + { + // create the common project and create an interface + project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin","1.5"); + createFolder("P/src/p478042"); + createFile("/P/src/p478042/AllMethodDeclarations01.java", + "package p478042;\n" + + "public class AllMethodDeclarations01 {\n" + + " public void foo01() {}\n" + + " public int foo02(Object o) {return null;}\n" + + " public char foo03(Object o, String s) {return null;}\n" + + " }"); + createFile("/P/src/p478042/AllMethodDeclarations01b.java", + "package p478042;\n" + + "public class AllMethodDeclarations01b {\n" + + " public Integer fooInt() {return null;}\n" + + " }"); + MethodDeclarationsCollector requestor = new MethodDeclarationsCollector(); + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.SOURCES); + searchAllMethodNames("foo", SearchPattern.R_PREFIX_MATCH, scope, requestor); + assertSearchResults( + "/P/src/p478042/AllMethodDeclarations01.java char p478042.AllMethodDeclarations01.foo03(Object o,String s)\n" + + "/P/src/p478042/AllMethodDeclarations01.java int p478042.AllMethodDeclarations01.foo02(Object o)\n" + + "/P/src/p478042/AllMethodDeclarations01.java void p478042.AllMethodDeclarations01.foo01()\n" + + "/P/src/p478042/AllMethodDeclarations01b.java Integer p478042.AllMethodDeclarations01b.fooInt()", + requestor + ); + } finally { + deleteProject(project); + } + } + public void testBug478042_0002() throws Exception { + IJavaProject project = null; + try + { + // create the common project and create an interface + project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin","1.5"); + createFolder("P/src/p478042"); + createFile("/P/src/p478042/AllMethodDeclarations01.java", + "package p478042;\n" + + "public class AllMethodDeclarations01 {\n" + + " public void foo01() {}\n" + + " public int foo02(Object o) {return null;}\n" + + " public char foo03(Object o, String s) {return null;}\n" + + " }"); + createFile("/P/src/p478042/AllMethodDeclarations01b.java", + "package p478042;\n" + + "public class AllMethodDeclarations01b {\n" + + " public Integer fooInt() {return null;}\n" + + " }"); + MethodDeclarationsCollector requestor = new MethodDeclarationsCollector(); + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.SOURCES); + searchAllMethodNames("foo", SearchPattern.R_PREFIX_MATCH, scope, requestor); + assertSearchResults( + "/P/src/p478042/AllMethodDeclarations01.java char p478042.AllMethodDeclarations01.foo03(Object o,String s)\n" + + "/P/src/p478042/AllMethodDeclarations01.java int p478042.AllMethodDeclarations01.foo02(Object o)\n" + + "/P/src/p478042/AllMethodDeclarations01.java void p478042.AllMethodDeclarations01.foo01()\n" + + "/P/src/p478042/AllMethodDeclarations01b.java Integer p478042.AllMethodDeclarations01b.fooInt()", + requestor + ); + } finally { + deleteProject(project); + } + } + public void testBug478042_0003() throws Exception { + IJavaProject project = null; + try { + project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin","1.5"); + createFolder("P/src/p478042"); + createFile("/P/src/p478042/AllMethodDeclarations01.java", + "package p478042;\n" + + "public class AllMethodDeclarations01 {\n" + + " public void foo() {}\n" + + " public void foo01() {}\n" + + " public int foo02(Object o) {return null;}\n" + + " public char foo03(Object o, String s) {return null;}\n" + + " }"); + createFile("/P/src/p478042/AllMethodDeclarations01b.java", + "package p478042;\n" + + "public class AllMethodDeclarations01b {\n" + + " public Integer fooInt() {return null;}\n" + + " }"); + class Collector extends MethodNameMatchRequestor { + List matches = new ArrayList<>(); + @Override + public void acceptMethodNameMatch(MethodNameMatch match) { + this.matches.add(match); + } + } + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.SOURCES); + Collector collector = new Collector(); + new SearchEngine().searchAllMethodNames( + null, SearchPattern.R_EXACT_MATCH, + null, SearchPattern.R_EXACT_MATCH, + "AllMethodDeclarations01".toCharArray(), SearchPattern.R_EXACT_MATCH, + "foo".toCharArray(), SearchPattern.R_PREFIX_MATCH, + scope, collector, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); + assertEquals(4, collector.matches.size()); + } finally { + deleteProject("P"); + } + } + public void testBug478042_0004() throws Exception { + IJavaProject project = null; + try + { + // create the common project and create an interface + project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin","1.5"); + createFolder("P/src/p478042"); + createFile("/P/src/p478042/AllMethodDeclarations01.java", + "package p478042;\n" + + "class Y {}\n" + + "class X {}\n" + + "public class AllMethodDeclarations01 {\n" + + " public Y foo01(Y t) {}\n" + + " public int foo02(Object o) {return null;}\n" + + " public char foo03(Object o, String s) {return null;}\n" + + "}"); + createFile("/P/src/p478042/AllMethodDeclarations01b.java", + "package p478042;\n" + + "public class AllMethodDeclarations01b {\n" + + " public Integer fooInt() {return null;}\n" + + "}"); + MethodDeclarationsCollector requestor = new MethodDeclarationsCollector(); + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.SOURCES); + searchAllMethodNames("foo", SearchPattern.R_PREFIX_MATCH, scope, requestor); + assertSearchResults( + "/P/src/p478042/AllMethodDeclarations01.java Y p478042.AllMethodDeclarations01.foo01(Y t)\n" + + "/P/src/p478042/AllMethodDeclarations01.java char p478042.AllMethodDeclarations01.foo03(Object o,String s)\n" + + "/P/src/p478042/AllMethodDeclarations01.java int p478042.AllMethodDeclarations01.foo02(Object o)\n" + + "/P/src/p478042/AllMethodDeclarations01b.java Integer p478042.AllMethodDeclarations01b.fooInt()", + requestor + ); + } finally { + deleteProject(project); + } + } + public void testBug478042_005() throws Exception { + try { + IJavaProject p = createJavaProject("P", new String[] {}, new String[] { "/P/lib478042.jar", "JCL15_LIB" }, "", "1.5"); + createJar(new String[] { + "p478042/AllMethodDeclarations02.java", + "package p478042;\n" + + "class X {}\n" + + "class Y{}\n" + + "public class AllMethodDeclarations02 {\n" + + " public Y foo01(Y t) { return null;}\n" + + " public int foo02(Object o) {return 0;}\n" + + " public char foo03(Object o, String s) {return '0';}\n" + + "}", + "p478042/AllMethodDeclarations02b.java", + "package p478042;\n" + + "class AllMethodDeclarations02b {\n" + + " public void fooInt() {}\n" + + "}" + }, p.getProject().getLocation().append("lib478042.jar").toOSString(), + new String[] { p.getProject().getLocation().append("lib478042.jar").toOSString() }, + "1.5"); + refresh(p); + + MethodDeclarationsCollector requestor = new MethodDeclarationsCollector(); + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES|IJavaSearchScope.APPLICATION_LIBRARIES); + searchAllMethodNames("foo", SearchPattern.R_PREFIX_MATCH, scope, requestor); + assertSearchResults( + "/P/lib478042.jar|p478042/AllMethodDeclarations02.class char p478042.AllMethodDeclarations02.foo03(java.lang.Object o,java.lang.String s)\n" + + "/P/lib478042.jar|p478042/AllMethodDeclarations02.class int p478042.AllMethodDeclarations02.foo02(java.lang.Object o)\n" + + "/P/lib478042.jar|p478042/AllMethodDeclarations02.class p478042.Y p478042.AllMethodDeclarations02.foo01(p478042.Y t)\n" + + "/P/lib478042.jar|p478042/AllMethodDeclarations02b.class void p478042.AllMethodDeclarations02b.fooInt()", + requestor + ); + } finally { + deleteProject("P"); + } + } + public void testBug478042_006() throws Exception { + try { + IJavaProject p = createJavaProject("P", new String[] {}, new String[] { "/P/lib478042.jar", "JCL15_LIB" }, "", "1.5"); + createJar(new String[] { + "p478042/AllMethodDeclarations01.java", + "package p478042;\n" + + "public class AllMethodDeclarations01 {\n" + + " public class Nested {\n" + + " public class Inner {\n" + + " public void foo01() {}\n" + + " public int foo02(Object o) {return 0;}\n" + + " public char foo03(Object o, String s) {return '0';}\n" + + " }\n" + + " }\n" + + "}\n" + }, p.getProject().getLocation().append("lib478042.jar").toOSString(), + new String[] { p.getProject().getLocation().append("lib478042.jar").toOSString() }, + "1.5"); + refresh(p); + + MethodDeclarationsCollector requestor = new MethodDeclarationsCollector(); + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES|IJavaSearchScope.APPLICATION_LIBRARIES); + searchAllMethodNames("foo", SearchPattern.R_PREFIX_MATCH, scope, requestor); + assertSearchResults( + "/P/lib478042.jar|p478042/AllMethodDeclarations01$Nested$Inner.class char p478042.Inner.foo03(java.lang.Object o,java.lang.String s)\n" + + "/P/lib478042.jar|p478042/AllMethodDeclarations01$Nested$Inner.class int p478042.Inner.foo02(java.lang.Object o)\n" + + "/P/lib478042.jar|p478042/AllMethodDeclarations01$Nested$Inner.class void p478042.Inner.foo01()", + requestor + ); + } finally { + deleteProject("P"); + } + } + public void testBug478042_007() throws Exception { + try { + IJavaProject p = createJavaProject("P", new String[] {}, new String[] { "/P/lib478042.jar", "JCL15_LIB" }, "", "1.5"); + createJar(new String[] { + "p478042/AllMethodDeclarations01.java", + "package p478042;\n" + + "public class AllMethodDeclarations01 {\n" + + " public class Nested {\n" + + " public class Inner {\n" + + " public void foo01() {}\n" + + " public int foo02(Object o) {return 0;}\n" + + " public char foo03(Object o, String s) {return '0';}\n" + + " }\n" + + " }\n" + + "}\n" + }, p.getProject().getLocation().append("lib478042.jar").toOSString(), + new String[] { p.getProject().getLocation().append("lib478042.jar").toOSString() }, + "1.5"); + refresh(p); + + MethodDeclarationsCollector requestor = new MethodDeclarationsCollector(); + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES|IJavaSearchScope.APPLICATION_LIBRARIES); + searchAllMethodNames( + "Inner", SearchPattern.R_EXACT_MATCH, + "foo", SearchPattern.R_PREFIX_MATCH, scope, requestor); + assertSearchResults( + "/P/lib478042.jar|p478042/AllMethodDeclarations01$Nested$Inner.class char p478042.Inner.foo03(java.lang.Object o,java.lang.String s)\n" + + "/P/lib478042.jar|p478042/AllMethodDeclarations01$Nested$Inner.class int p478042.Inner.foo02(java.lang.Object o)\n" + + "/P/lib478042.jar|p478042/AllMethodDeclarations01$Nested$Inner.class void p478042.Inner.foo01()", + requestor + ); + } finally { + deleteProject("P"); + } + } + public void testBug478042_008() throws Exception { + IJavaProject project = null; + try + { + // create the common project and create an interface + project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin","1.5"); + createFolder("P/src/p478042"); + createFile("/P/src/p478042/AllMethodDeclarations01.java", + "package p478042;\n" + + "public class AllMethodDeclarations01 {\n" + + " public class Nested {\n" + + " public class Inner {\n" + + " public void foo01() {}\n" + + " public int foo02(Object o) {return 0;}\n" + + " public char foo03(Object o, String s) {return '0';}\n" + + " }\n" + + " }\n" + + "}"); + MethodDeclarationsCollector requestor = new MethodDeclarationsCollector(); + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.SOURCES); + searchAllMethodNames("foo", SearchPattern.R_PREFIX_MATCH, scope, requestor); + assertSearchResults( + "/P/src/p478042/AllMethodDeclarations01.java char p478042.AllMethodDeclarations01.Nested.Inner.foo03(Object o,String s)\n" + + "/P/src/p478042/AllMethodDeclarations01.java int p478042.AllMethodDeclarations01.Nested.Inner.foo02(Object o)\n" + + "/P/src/p478042/AllMethodDeclarations01.java void p478042.AllMethodDeclarations01.Nested.Inner.foo01()", + requestor + ); + } catch(Exception e) { + e.printStackTrace(); + } finally { + deleteProject(project); + } + } + public void testBug483303_001() throws Exception { + IJavaProject project = null; + try { + project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin","1.5"); + createFolder("P/src/p478042"); + createFile("/P/src/p478042/AllMethodDeclarations01.java", + "package p478042;\n" + + "public class AllMethodDeclarations01 {\n" + + " public void m1(int i) {}\n" + + " public void foo01() {}\n" + + " public int foo02(Object o) {return null;}\n" + + " public char foo03(Object o, String s) {return null;}\n" + + " }"); + createFile("/P/src/p478042/AllMethodDeclarations01b.java", + "package p478042;\n" + + "public class AllMethodDeclarations01b {\n" + + " public Integer fooInt() {return null;}\n" + + " }"); + class Collector extends MethodNameMatchRequestor { + List matches = new ArrayList<>(); + @Override + public void acceptMethodNameMatch(MethodNameMatch match) { + this.matches.add(match); + } + } + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.SOURCES); + Collector collector = new Collector(); + new SearchEngine().searchAllMethodNames( + null, SearchPattern.R_EXACT_MATCH, + null, SearchPattern.R_EXACT_MATCH, + "AllMethodDeclarations01".toCharArray(), SearchPattern.R_EXACT_MATCH, + "m1".toCharArray(), SearchPattern.R_PREFIX_MATCH, + scope, collector, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); + assertEquals(1, collector.matches.size()); + IMethod method = collector.matches.get(0).getMethod(); + assertTrue(method.exists()); + } finally { + deleteProject("P"); + } + } + public void testBug483650_0001() throws Exception { + IJavaProject project = null; + try + { + // create the common project and create an interface + project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin","1.5"); + createFolder("P/src/p478042"); + createFile("/P/src/p478042/AllMethodDeclarations01.java", + "package p478042;\n" + + "public class AllMethodDeclarations01 {\n" + + " public void foo01() {}\n" + + " public int foo02(Object o) {return null;}\n" + + " public char foo03(Object o, String s) {return null;}\n" + + " }"); + createFile("/P/src/p478042/AllMethodDeclarations01b.java", + "package p478042;\n" + + "public class AllMethodDeclarations01b {\n" + + " public Integer fooInt() {return null;}\n" + + " }"); + MethodNameMatchCollector collector = new MethodNameMatchCollector() { + @Override + public String toString() { + return toFullyQualifiedNamesString(); + } + }; + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.SOURCES); + searchAllMethodNames("*", SearchPattern.R_PATTERN_MATCH, "foo", SearchPattern.R_PREFIX_MATCH, scope, collector); + assertSearchResults( + "/P/src/p478042/AllMethodDeclarations01.java void p478042.AllMethodDeclarations01.foo01()\n" + + "/P/src/p478042/AllMethodDeclarations01.java char p478042.AllMethodDeclarations01.foo03(Object o,String s)\n" + + "/P/src/p478042/AllMethodDeclarations01.java int p478042.AllMethodDeclarations01.foo02(Object o)\n" + + "/P/src/p478042/AllMethodDeclarations01b.java Integer p478042.AllMethodDeclarations01b.fooInt()", + collector + ); + } finally { + deleteProject(project); + } + } + public void testBug483650_0002() throws Exception { + IJavaProject project = null; + try + { + // create the common project and create an interface + project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin","1.5"); + createFolder("P/src/p478042"); + createFile("/P/src/p478042/AllMethodDeclarations01.java", + "package p478042;\n" + + "public class AllMethodDeclarations01 {\n" + + " public void foo01() {}\n" + + " public int foo02(Object o) {return null;}\n" + + " public char foo03(Object o, String s) {return null;}\n" + + " }"); + createFile("/P/src/p478042/AllMethodDeclarations01b.java", + "package p478042;\n" + + "public class AllMethodDeclarations01b {\n" + + " public Integer fooInt() {return null;}\n" + + " }"); + MethodNameMatchCollector collector = new MethodNameMatchCollector() { + @Override + public String toString() { + return toFullyQualifiedNamesString(); + } + }; + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.SOURCES); + searchAllMethodNames("*", SearchPattern.R_PATTERN_MATCH, "foo", SearchPattern.R_PREFIX_MATCH, scope, collector); + assertSearchResults( + "/P/src/p478042/AllMethodDeclarations01.java void p478042.AllMethodDeclarations01.foo01()\n" + + "/P/src/p478042/AllMethodDeclarations01.java char p478042.AllMethodDeclarations01.foo03(Object o,String s)\n" + + "/P/src/p478042/AllMethodDeclarations01.java int p478042.AllMethodDeclarations01.foo02(Object o)\n" + + "/P/src/p478042/AllMethodDeclarations01b.java Integer p478042.AllMethodDeclarations01b.fooInt()", + collector + ); + } finally { + deleteProject(project); + } + } + public void testBug483650_0003() throws Exception { + IJavaProject project = null; + try { + project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin","1.5"); + createFolder("P/src/p478042"); + createFile("/P/src/p478042/AllMethodDeclarations01.java", + "package p478042;\n" + + "public class AllMethodDeclarations01 {\n" + + " public void foo() {}\n" + + " public void foo01() {}\n" + + " public int foo02(Object o) {return null;}\n" + + " public char foo03(Object o, String s) {return null;}\n" + + " }"); + createFile("/P/src/p478042/AllMethodDeclarations01b.java", + "package p478042;\n" + + "public class AllMethodDeclarations01b {\n" + + " public Integer fooInt() {return null;}\n" + + " }"); + class Collector extends MethodNameMatchRequestor { + List matches = new ArrayList<>(); + @Override + public void acceptMethodNameMatch(MethodNameMatch match) { + this.matches.add(match); + } + } + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.SOURCES); + Collector collector = new Collector(); + new SearchEngine().searchAllMethodNames( + "*.AllMethodDeclarations01".toCharArray(), SearchPattern.R_PATTERN_MATCH, + "foo".toCharArray(), SearchPattern.R_PREFIX_MATCH, + scope, collector, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); + assertEquals(4, collector.matches.size()); + } finally { + deleteProject("P"); + } + } + public void testBug483650_0004() throws Exception { + IJavaProject project = null; + try + { + // create the common project and create an interface + project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin","1.5"); + createFolder("P/src/p478042"); + createFile("/P/src/p478042/AllMethodDeclarations01.java", + "package p478042;\n" + + "class Y {}\n" + + "class X {}\n" + + "public class AllMethodDeclarations01 {\n" + + " public Y foo01(Y t) {}\n" + + " public int foo02(Object o) {return null;}\n" + + " public char foo03(Object o, String s) {return null;}\n" + + "}"); + createFile("/P/src/p478042/AllMethodDeclarations01b.java", + "package p478042;\n" + + "public class AllMethodDeclarations01b {\n" + + " public Integer fooInt() {return null;}\n" + + "}"); + MethodNameMatchCollector collector = new MethodNameMatchCollector() { + @Override + public String toString() { + return toFullyQualifiedNamesString(); + } + }; + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.SOURCES); + searchAllMethodNames("*", SearchPattern.R_PATTERN_MATCH, "foo", SearchPattern.R_PREFIX_MATCH, scope, collector); + assertSearchResults( + "/P/src/p478042/AllMethodDeclarations01.java Y p478042.AllMethodDeclarations01.foo01(Y t)\n" + + "/P/src/p478042/AllMethodDeclarations01.java char p478042.AllMethodDeclarations01.foo03(Object o,String s)\n" + + "/P/src/p478042/AllMethodDeclarations01.java int p478042.AllMethodDeclarations01.foo02(Object o)\n" + + "/P/src/p478042/AllMethodDeclarations01b.java Integer p478042.AllMethodDeclarations01b.fooInt()", + collector + ); + } finally { + deleteProject(project); + } + } + public void testBug483650_005() throws Exception { + try { + IJavaProject p = createJavaProject("P", new String[] {}, new String[] { "/P/lib478042.jar", "JCL15_LIB" }, "", "1.5"); + createJar(new String[] { + "p478042/AllMethodDeclarations02.java", + "package p478042;\n" + + "class X {}\n" + + "class Y{}\n" + + "public class AllMethodDeclarations02 {\n" + + " public Y foo01(Y t) { return null;}\n" + + " public int foo02(Object o) {return 0;}\n" + + " public char foo03(Object o, String s) {return '0';}\n" + + "}", + "p478042/AllMethodDeclarations02b.java", + "package p478042;\n" + + "class AllMethodDeclarations02b {\n" + + " public void fooInt() {}\n" + + "}" + }, p.getProject().getLocation().append("lib478042.jar").toOSString(), + new String[] { p.getProject().getLocation().append("lib478042.jar").toOSString() }, + "1.5"); + refresh(p); + + MethodNameMatchCollector collector = new MethodNameMatchCollector() { + @Override + public String toString() { + return toFullyQualifiedNamesString(); + } + }; + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES|IJavaSearchScope.APPLICATION_LIBRARIES); + searchAllMethodNames("*", SearchPattern.R_PATTERN_MATCH, "foo", SearchPattern.R_PREFIX_MATCH, scope, collector); + assertSearchResults( + "/P/lib478042.jar p478042.Y p478042.AllMethodDeclarations02.foo01(p478042.Y t)\n" + + "/P/lib478042.jar void p478042.AllMethodDeclarations02b.fooInt()\n" + + "/P/lib478042.jar int p478042.AllMethodDeclarations02.foo02(java.lang.Object o)\n" + + "/P/lib478042.jar char p478042.AllMethodDeclarations02.foo03(java.lang.Object o,java.lang.String s)", + collector + ); + } finally { + deleteProject("P"); + } + } + public void testBug483650_006() throws Exception { + try { + IJavaProject p = createJavaProject("P", new String[] {}, new String[] { "/P/lib478042.jar", "JCL15_LIB" }, "", "1.5"); + createJar(new String[] { + "p478042/AllMethodDeclarations01.java", + "package p478042;\n" + + "public class AllMethodDeclarations01 {\n" + + " public class Nested {\n" + + " public class Inner {\n" + + " public void foo01() {}\n" + + " public int foo02(Object o) {return 0;}\n" + + " public char foo03(Object o, String s) {return '0';}\n" + + " }\n" + + " }\n" + + "}\n" + }, p.getProject().getLocation().append("lib478042.jar").toOSString(), + new String[] { p.getProject().getLocation().append("lib478042.jar").toOSString() }, + "1.5"); + refresh(p); + + MethodNameMatchCollector collector = new MethodNameMatchCollector() { + @Override + public String toString() { + return toFullyQualifiedNamesString(); + } + }; + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES|IJavaSearchScope.APPLICATION_LIBRARIES); + searchAllMethodNames("*", SearchPattern.R_PATTERN_MATCH, "foo", SearchPattern.R_PREFIX_MATCH, scope, collector); + assertSearchResults( + "/P/lib478042.jar void p478042.AllMethodDeclarations01.Nested.Inner.foo01()\n" + + "/P/lib478042.jar int p478042.AllMethodDeclarations01.Nested.Inner.foo02(java.lang.Object o)\n" + + "/P/lib478042.jar char p478042.AllMethodDeclarations01.Nested.Inner.foo03(java.lang.Object o,java.lang.String s)", + collector + ); + } finally { + deleteProject("P"); + } + } + public void testBug483650_007() throws Exception { + try { + IJavaProject p = createJavaProject("P", new String[] {}, new String[] { "/P/lib478042.jar", "JCL15_LIB" }, "", "1.5"); + createJar(new String[] { + "p478042/AllMethodDeclarations01.java", + "package p478042;\n" + + "public class AllMethodDeclarations01 {\n" + + " public class Nested {\n" + + " public class Inner {\n" + + " public void foo01() {}\n" + + " public int foo02(Object o) {return 0;}\n" + + " public char foo03(Object o, String s) {return '0';}\n" + + " }\n" + + " }\n" + + "}\n" + }, p.getProject().getLocation().append("lib478042.jar").toOSString(), + new String[] { p.getProject().getLocation().append("lib478042.jar").toOSString() }, + "1.5"); + refresh(p); + + MethodNameMatchCollector collector = new MethodNameMatchCollector() { + @Override + public String toString() { + return toFullyQualifiedNamesString(); + } + }; + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, IJavaSearchScope.SOURCES|IJavaSearchScope.APPLICATION_LIBRARIES); + searchAllMethodNames( + "*Inner", SearchPattern.R_PATTERN_MATCH, + "foo", SearchPattern.R_PREFIX_MATCH, scope, collector); + assertSearchResults( + "/P/lib478042.jar void p478042.AllMethodDeclarations01.Nested.Inner.foo01()\n" + + "/P/lib478042.jar int p478042.AllMethodDeclarations01.Nested.Inner.foo02(java.lang.Object o)\n" + + "/P/lib478042.jar char p478042.AllMethodDeclarations01.Nested.Inner.foo03(java.lang.Object o,java.lang.String s)", + collector + ); + } finally { + deleteProject("P"); + } + } + public void testBug483650_008() throws Exception { + IJavaProject project = null; + try + { + // create the common project and create an interface + project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin","1.5"); + createFolder("P/src/p478042"); + createFile("/P/src/p478042/AllMethodDeclarations01.java", + "package p478042;\n" + + "public class AllMethodDeclarations01 {\n" + + " public class Nested {\n" + + " public class Inner {\n" + + " public void foo01() {}\n" + + " public int foo02(Object o) {return 0;}\n" + + " public char foo03(Object o, String s) {return '0';}\n" + + " }\n" + + " }\n" + + "}"); + MethodNameMatchCollector collector = new MethodNameMatchCollector() { + @Override + public String toString() { + return toFullyQualifiedNamesString(); + } + }; + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.SOURCES); + searchAllMethodNames("*", SearchPattern.R_PATTERN_MATCH, "foo", SearchPattern.R_PREFIX_MATCH, scope, collector); + assertTrue(collector.matches.size() == 3); + } catch(Exception e) { + e.printStackTrace(); + } finally { + deleteProject(project); + } + } + public void testBug483650_009() throws Exception { + IJavaProject project = null; + try { + project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin","1.5"); + createFolder("P/src/p478042"); + createFile("/P/src/p478042/AllMethodDeclarations01.java", + "package p478042;\n" + + "public class AllMethodDeclarations01 {\n" + + " public void m1(int i) {}\n" + + " public void foo01() {}\n" + + " public int foo02(Object o) {return null;}\n" + + " public char foo03(Object o, String s) {return null;}\n" + + " }"); + createFile("/P/src/p478042/AllMethodDeclarations01b.java", + "package p478042;\n" + + "public class AllMethodDeclarations01b {\n" + + " public Integer fooInt() {return null;}\n" + + " }"); + class Collector extends MethodNameMatchRequestor { + List matches = new ArrayList<>(); + @Override + public void acceptMethodNameMatch(MethodNameMatch match) { + this.matches.add(match); + } + } + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.SOURCES); + Collector collector = new Collector(); + new SearchEngine().searchAllMethodNames( + "*.AllMethodDeclarations01".toCharArray(), SearchPattern.R_PATTERN_MATCH, + "m1".toCharArray(), SearchPattern.R_PREFIX_MATCH, + scope, collector, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); + assertEquals(1, collector.matches.size()); + IMethod method = collector.matches.get(0).getMethod(); + assertTrue(method.exists()); + } finally { + deleteProject("P"); + } + } + public void testBug489404() throws CoreException, IOException { + try { + IJavaProject p = createJavaProject("P", new String[] { "src" }, new String[] { "/P/p1p2.jar", "JCL15_LIB" }, "bin", "1.5"); + org.eclipse.jdt.core.tests.util.Util.createJar(new String[] { + "p1/MissingClass.java", + "package p1;\n" + + "public class MissingClass{}\n" }, + p.getProject().getLocation().append("p1.jar").toOSString(), "1.5"); + + org.eclipse.jdt.core.tests.util.Util.createJar(new String[] { + "p1/p2/BinaryWithField.java", + "package p1.p2;\n" + + "import p1.MissingClass;\n" + + "public class BinaryWithField {\n" + + " public class Binary {\n" + + " }\n" + + " MissingClass f;\n" + + "}\n", + "p1/p2/BinaryWithMethod.java", + "package p1.p2;\n" + + "import p1.MissingClass;\n" + + "public class BinaryWithMethod {\n" + + " public class Binary {\n" + + " }\n" + + " MissingClass m() {\n" + + " return null;\n" + + " }\n" + + "}\n"}, + null, + p.getProject().getLocation().append("p1p2.jar").toOSString(), + new String[] { p.getProject().getLocation().append("p1.jar").toOSString() }, + "1.5"); + createFolder("/P/src/test"); + createFile("/P/src/test/A.java", + "package test;\n" + + "import p1.MissingClass;\n" + + "public class A {\n" + + " MissingClass m() {\n" + + " return null;\n" + + " }\n" + + "}\n"); + createFile("/P/src/test/TestSearchBug.java", + "package test;\n" + + "\n" + + "public class TestSearchBug {\n" + + " public String lang;\n" + + "}\n"); + refresh(p); + waitUntilIndexesReady(); + IType type = getCompilationUnit("/P/src/test/TestSearchBug.java").getType("TestSearchBug"); + IField field = type.getField("lang"); + search(field, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults( + "Unexpected search results!", + "", + this.resultCollector); + } finally { + deleteProject("P"); + } + } + public void testBug491656_001() throws CoreException, IOException { + try { + IJavaProject p = createJavaProject("P", new String[] { "src" }, new String[] { "JCL15_LIB", "/P/lib491656_001.jar" }, "bin", "1.5"); + String libsource = "package p2;\n" + + "import java.util.HashMap;\n"+ + "import java.util.Map;\n"+ + "\n"+ + "public class MyLinkedHashMap\n"+ + " extends HashMap\n"+ + " implements Map\n"+ + "{\n"+ + " private transient Entry header;\n"+ + " public MyLinkedHashMap(int initialCapacity, float loadFactor) {\n"+ + " super(initialCapacity, loadFactor);\n"+ + " }\n"+ + " private static class Entry {\n"+ + " public Object hash;\n"+ + " Entry before, after;\n"+ + "\n"+ + " Entry(int hash, K key, V value, HashMap.Entry next) {}\n"+ + " private void remove491656() {}\n"+ + " private void remove491656Test() {}\n"+ + "\n"+ + " private void addBefore491656(Entry existingEntry) {}\n"+ + " public void iamAPublicMethod491656(Entry existingEntry) {}\n"+ + "\n"+ + " void recordAccess(HashMap m) {\n"+ + " MyLinkedHashMap lm = (MyLinkedHashMap)m;\n"+ + " remove491656();\n"+ + " remove491656Test();\n"+ + " addBefore491656(lm.header);\n"+ + " iamAPublicMethod491656(lm.header);\n"+ + " }\n"+ + " }\n"+ + "}\n"; + String jarFileName = "lib491656_001.jar"; + String srcZipName = "lib491656_001.src.zip"; + createLibrary(p, jarFileName, srcZipName, new String[] {"p2/MyLinkedHashMap.java",libsource}, new String[0], JavaCore.VERSION_1_5); + IFile srcZip=(IFile) p.getProject().findMember(srcZipName); + IFile jar = (IFile) p.getProject().findMember(jarFileName); + p.getPackageFragmentRoot(jar).attachSource(srcZip.getFullPath(), null, null); + refresh(p); + waitUntilIndexesReady(); + IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); + IType enclosingType = p.findType("p2.MyLinkedHashMap"); + IType[] types = enclosingType.getTypes(); + IMethod[] methods = types[0].getMethods(); + IMethod method = methods[3]; + assertTrue("Wrong Method", method.toString().contains("addBefore491656")); + SearchPattern pattern = SearchPattern.createPattern(method, REFERENCES); + MatchLocator.setFocus(pattern, method); + new SearchEngine(this.workingCopies).search( + pattern, + new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, + getJavaSearchScope(), + this.resultCollector, + null + ); + search(pattern, scope, this.resultCollector); + assertSearchResults( + "lib491656_001.jar void p2.MyLinkedHashMap$Entry.recordAccess(java.util.HashMap) EXACT_MATCH"); + } finally { + deleteProject("P"); + } + } + + /** + * Test that a diamond in a type name doesn't result in an AIOOBE during a search. + * See: https://github.com/eclipse-jdt/eclipse.jdt.core/issues/825 + */ + public void testOutOfBoundsIndexExceptionDuringSearchGh825() throws Exception { + String projectName = "testGh825"; + try { + IJavaProject project = createJavaProject(projectName, new String[] {"src"}, new String[] {"JCL11_LIB"}, "bin", "11"); + String srcFolder = "/" + projectName + "/src/"; + String packageFolder = srcFolder + "test"; + createFolder(packageFolder); + String snippet = String.join(System.lineSeparator(), new String[] { + "package test;", + "public class Test {", + " public interface TestInterface {", + " void testMethod(T t);", + " }", + " TestInterface SUP = new TestInterface<>() {", + " public void testMethod(String s) {}", + " };", + " static void shouldFail() {}", + "}", + }); + createFile(packageFolder + "/Test.java", snippet); + + String module = "module tester {}"; + createFile(srcFolder + "/module-info.java", module); + + String testFolder = "/" + projectName + "/test"; + createFolder(testFolder); + IClasspathAttribute[] testAttrs = { JavaCore.newClasspathAttribute(IClasspathAttribute.TEST, Boolean.toString(true)) }; + addClasspathEntry(project, JavaCore.newSourceEntry( + new Path(testFolder), + null, + null, + new Path("/" + projectName + "/bin-test"), + testAttrs)); + + addLibrary(project, + "libGh825.jar", + "libGh825.src.zip", + new String[] { + "testpackage/TestClass.java", + "package testpackage;\n" + + "public class TestClass {}" + }, + JavaCore.VERSION_11); + + buildAndExpectNoProblems(project); + IType type = project.findType("test.Test"); + IMethod method = type.getMethod("shouldFail", new String[0]); + search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + // we expect no matches and no exceptions + assertSearchResults(""); + } finally { + deleteProject(projectName); + } + } + + /** + * Test that an inner class constructor with first argument of the outer type + * doesn't result in no search matches. + * See: https://github.com/eclipse-jdt/eclipse.jdt.core/issues/401 + */ + public void testInnerConstructorWithOuterTypeArgumentGh401() throws Exception { + String projectName = "testGh401"; + try { + IJavaProject project = createJavaProject(projectName, new String[] {"src"}, new String[] {"JCL11_LIB"}, "bin", "11"); + String srcFolder = "/" + projectName + "/src/"; + String packageFolder = srcFolder + "test1"; + createFolder(packageFolder); + String snippet1 = + """ + package test1; + public final class Outer1 { + public void staticConstructorCaller() { + new StaticInner1(this); + } + public void constructorCaller() { + new Inner1(this); + } + private static final class StaticInner1 { + StaticInner1(Outer1 o) {} + } + private final class Inner1 { + Inner1(Outer1 o) {} + } + } + """; + createFile(packageFolder + "/Outer1.java", snippet1); + + addLibrary(project, + "libGh401.jar", + "libGh401.src.zip", + new String[] { + "test2/Outer2.java", + """ + package test2; + public final class Outer2 { + public void staticConstructorCaller() { + new StaticInner2(this); + } + public void constructorCaller() { + new Inner2(this); + } + private static final class StaticInner2 { + StaticInner2(Outer2 o) {} + } + private final class Inner2 { + Inner2(Outer2 o) {} + } + } + """, + }, + JavaCore.VERSION_11); + + buildAndExpectNoProblems(project); + + String[] typesAndExpcetedMatches = { + "test1.Outer1.StaticInner1", + "src/test1/Outer1.java void test1.Outer1.staticConstructorCaller() [new StaticInner1(this)] EXACT_MATCH", + "test1.Outer1.Inner1", + "src/test1/Outer1.java void test1.Outer1.constructorCaller() [new Inner1(this)] EXACT_MATCH", + "test2.Outer2.StaticInner2", + "libGh401.jar void test2.Outer2.staticConstructorCaller() EXACT_MATCH", + "test2.Outer2.Inner2", + "libGh401.jar void test2.Outer2.constructorCaller() EXACT_MATCH", + + }; + + for (int i = 0; i < typesAndExpcetedMatches.length; i += 2) { + String type = typesAndExpcetedMatches[i + 0]; + String expectedMatch = typesAndExpcetedMatches[i + 1]; + IType staticInnerType = project.findType(type); + IMethod staticInnerConstructor = staticInnerType.getMethods()[0]; + search(staticInnerConstructor, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults(expectedMatch); + this.resultCollector.clear(); + } + } finally { + deleteProject(projectName); + } + } + + /** + *
For the following scenario, no call hierarchy is found:
+ * A nested private class implements a public nested interface. + * The overridden method from the interface also has an argument of the interface type. + * No call hierarchy is found for the overridden method, when searching from within the nested class. + * See: https://github.com/eclipse-jdt/eclipse.jdt.core/issues/821 + */ + public void testCallHierarchyWithNestedInterfacesGh821() throws Exception { + String projectName = "TestCallHierarchyWithNestedInterfacesGh821"; + try { + IJavaProject project = createJavaProject(projectName, new String[] { "src" }, new String[] { "JCL15_LIB" }, "bin", "1.5"); + String packageFolder = "/" + projectName + "/src/test"; + createFolder(packageFolder); + String snippet1 = + """ + package test; + public class TestNestedPrivateClass { + public NestedInterface nm = new NC(); + public interface NestedInterface { + public void foo(NestedInterface arg); + } + private final class NC implements NestedInterface { + public void foo(NestedInterface arg) {} + } + } + """; + createFile(packageFolder + "/TestNestedPrivateClass.java", snippet1); + String snippet2 = + """ + package test; + public class TestReferencingClass { + public static void bar() { + TestNestedPrivateClass c = new TestNestedPrivateClass(); + TestNestedPrivateClass.NestedInterface nestedMember = c.nm; + nestedMember.foo(nestedMember); + } + } + """; + createFile(packageFolder + "/TestReferencingClass.java", snippet2); + buildAndExpectNoProblems(project); + IType type = project.findType("test.TestNestedPrivateClass.NC"); + IMethod[] methods = type.getMethods(); + assertEquals("Expected one method in: " + Arrays.asList(methods), 1, methods.length); + search(methods[0], REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); + assertSearchResults( + "src/test/TestReferencingClass.java void test.TestReferencingClass.bar() [foo(nestedMember)] EXACT_MATCH"); + } finally { + deleteProject(projectName); + } + } + + private static void printJavaElements(IJavaProject javaProject, PrintStream output) throws Exception { + output.println("Printing Java elements of Java project: " + javaProject); + List queue = new LinkedList<>(); + while (!queue.isEmpty()) { + IJavaElement element = queue.remove(queue.size() - 1); + output.println(element); + output.print(element); + if (element instanceof IParent) { + IParent parent = (IParent) element; + queue.addAll(Arrays.asList(parent.getChildren())); + } + } + } + + private static void printZipContents(File jarFile, PrintStream output) throws Exception { + if (jarFile.exists()) { + output.println("Listing contents of jar file: " + jarFile); + try (ZipFile zipFile = new ZipFile(jarFile)) { + Enumeration entries = zipFile.entries(); + while (entries.hasMoreElements()) { + ZipEntry zipEntry = entries.nextElement(); + String zipEntryName = zipEntry.getName(); + output.println("Listing contents of zip entry: " + zipEntryName); + InputStream zipEntryInputStream = zipFile.getInputStream(zipEntry); + if (zipEntryName.endsWith(".class")) { + byte[] classFileBytes = toByteArray(zipEntryInputStream); + ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); + String classContents = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); + output.println(classContents); + } else { + @SuppressWarnings("resource") // the zip file resource-try will close the stream + Scanner scanner = new Scanner(zipEntryInputStream); + while (scanner.hasNextLine()) { + output.println(scanner.nextLine()); + } + } + } + } + } else { + output.println("File does not exist: " + jarFile); + } + } + + private static byte[] toByteArray(InputStream inputStream) throws IOException { + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + byte[] data = new byte[8192]; + + int nRead; + while ((nRead = inputStream.read(data, 0, data.length)) != -1) { + buffer.write(data, 0, nRead); + } + + return buffer.toByteArray(); + } + + private void assertUTF8Encoding() { + String fileEncodingVMProperty = System.getProperty("file.encoding"); + Charset defaultCharset = Charset.defaultCharset(); + String langEnvVariable = System.getenv("LANG"); + StringBuilder errorMessage = new StringBuilder(); + errorMessage.append(System.lineSeparator()); + errorMessage.append("Unexpected encoding during test, encoding parameters are:"); + errorMessage.append(System.lineSeparator()); + errorMessage.append("-Dfile.encoding=" + fileEncodingVMProperty); + errorMessage.append(System.lineSeparator()); + errorMessage.append("Charset.defaultCharset()=" + defaultCharset); + errorMessage.append(System.lineSeparator()); + errorMessage.append("LANG=" + langEnvVariable); + + assertEquals("unexpected default charset " + errorMessage, StandardCharsets.UTF_8, defaultCharset); + if (Constants.OS_LINUX.equals(System.getProperty("osgi.os"))) { + assertNotNull("expected LANG environment variable to be set" + errorMessage, langEnvVariable); + String utf8LANGRegexp = ".*\\.(UTF-8|UTF8|utf-8|utf8)"; + Pattern utf8LANGPattern = Pattern.compile(utf8LANGRegexp); + Matcher LANGMatcher = utf8LANGPattern.matcher(langEnvVariable); + assertTrue("expected encoding set with LANG environment variable to match regexp: " + utf8LANGRegexp + ", LANG=" + langEnvVariable + errorMessage, + LANGMatcher.matches()); + } + } } \ No newline at end of file diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests12To15.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests12To15.java index 75b10d32250..682642e17ff 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests12To15.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests12To15.java @@ -1405,7 +1405,7 @@ void getTarget() { }; } } - } + } """); String str = this.wc.getSource(); String selection = "/*here*/getTarget"; @@ -1553,7 +1553,7 @@ public static void main(String[] args) { } } } - } + } """); String str = this.wc.getSource(); String selection = "row"; diff --git a/org.eclipse.jdt.core.tests.model/workspace/Compiler/src/org/eclipse/jdt/internal/compiler/parser/parser19.rsc b/org.eclipse.jdt.core.tests.model/workspace/Compiler/src/org/eclipse/jdt/internal/compiler/parser/parser19.rsc index 3e90944f21e..a00f70b7d13 100644 --- a/org.eclipse.jdt.core.tests.model/workspace/Compiler/src/org/eclipse/jdt/internal/compiler/parser/parser19.rsc +++ b/org.eclipse.jdt.core.tests.model/workspace/Compiler/src/org/eclipse/jdt/internal/compiler/parser/parser19.rsc @@ -1,2 +1,2 @@ -ffFFFBBhAAA!BFeAdAI +ffFFFBBhAAA!BFeAdAI KK!BBB gJJH!G!!!! \ No newline at end of file diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/src/b573388/C.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/src/b573388/C.java index a0600bb37a7..ff6dec738ab 100644 --- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/src/b573388/C.java +++ b/org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/src/b573388/C.java @@ -1,4 +1,4 @@ -package b573388; - -public class C { -} +package b573388; + +public class C { +} diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/src/b573388/R.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/src/b573388/R.java index 4b9bdcf92d5..247b0966aa8 100644 --- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/src/b573388/R.java +++ b/org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/src/b573388/R.java @@ -1,4 +1,4 @@ -package b573388; - -public record R(int a) { -} +package b573388; + +public record R(int a) { +} diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/src/b573388/X.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/src/b573388/X.java index 12b9ffd1455..f4fa221f827 100644 --- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/src/b573388/X.java +++ b/org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/src/b573388/X.java @@ -1,8 +1,8 @@ -package b573388; - -public class XA { - public static void main(String[] args) { - R r= new R(7); - C c= new C(); - } -} +package b573388; + +public class XA { + public static void main(String[] args) { + R r= new R(7); + C c= new C(); + } +}