updated jdt.core and tests to v_B59 ( = 3.7 RC1)
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 28ab368..c9de30f 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
@@ -62,7 +62,7 @@
Map formatterOptions;
static {
-// TESTS_NUMBERS = new int[] { 738 };
+// TESTS_NUMBERS = new int[] { 558, 559, 575, 727, 728 };
// TESTS_RANGE = new int[] { 734, -1 };
}
public static Test suite() {
@@ -8007,7 +8007,10 @@
public void test558() {
Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings();
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER, 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
@@ -8044,7 +8047,10 @@
*/
public void test559() {
Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings();
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER, 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
@@ -8345,7 +8351,10 @@
public void test575() {
Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER, 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
@@ -10831,7 +10840,10 @@
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_MEMBER, 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);
+ 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" +
@@ -10864,10 +10876,15 @@
*/
public void test728() {
this.formatterPrefs = null;
+ 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" +
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java
index f4d365a..0d6ad4d 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java
@@ -30,6 +30,7 @@
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.IBuffer;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.IJavaElement;
@@ -606,6 +607,33 @@
}
}
/*
+ * Test that a path must have at least one segment
+ */
+public void test264301() throws CoreException {
+ String os = Platform.getOS();
+ if (!Platform.OS_WIN32.equals(os)) {
+ return;
+ }
+
+ try {
+ IJavaProject javaProject = createJavaProject("Test", new String[]{""}, new String[]{"/AttachSourceTests/test.jar"}, "");
+ createFolder("/Test/test1");
+ createFile("/Test/test1/Test.java",
+ "package test1;\n" +
+ "\n" +
+ "public class Test {}");
+ IPackageFragmentRoot root = javaProject.getPackageFragmentRoot(getFile("/AttachSourceTests/test.jar"));
+ try {
+ attachSource(root, "C:/", null);
+ assertTrue("Should not be there", false);
+ } catch(JavaModelException e) {
+ // expected exception
+ }
+ } finally {
+ deleteProject("Test");
+ }
+}
+/*
* Ensures that the source of a generic method can be retrieved.
*/
public void testGeneric1() throws JavaModelException {
@@ -985,7 +1013,6 @@
type.getSource());
attachSource(root, null, null); // detach source
}
-
/**
* Ensures that a source folder can be attached to a lib folder.
*/
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/BindingKeyTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/BindingKeyTests.java
index 6ce4b34..b121e69 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/BindingKeyTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/BindingKeyTests.java
@@ -639,4 +639,26 @@
"LNullBinding~One<[LNullBinding~Outer<Ljava/lang/Integer;>.Inner<Ljava/lang/Double;>;>;"
);
}
+ /*
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=336451
+ * Make sure that the binding obtained is a type binding corresponding to the
+ * method type variables
+ */
+ public void test057() {
+ assertBindingKeySignatureEquals(
+ "TT;",
+ "LEclipseTest$InvokerIF;.invoke<T::LEclipseTest$ArgIF;>(TT;)TT;|Ljava/lang/RuntimeException;:TT;"
+ );
+ }
+ /*
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=336451
+ * Make sure that the binding obtained is a type binding corresponding to the
+ * method type variables. In this case method has 2 exceptions and 2 type variables.
+ */
+ public void test058() {
+ assertBindingKeySignatureEquals(
+ "TT;",
+ "LEclipseTest$InvokerIF;.invoke<T::LEclipseTest$ArgIF;Y:Ljava/lang/Object;>(TT;)TT;|Ljava/lang/RuntimeException;|Ljava/lang/IndexOutOfBoundsException;:TT;"
+ );
+ }
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java
index f831934..4166cb2 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java
@@ -4360,11 +4360,11 @@
"");
this.assertMarkers(
"Unexpected markers for project A",
- "A cycle was detected in the build path of project 'A'",
+ "A cycle was detected in the build path of project 'A'. The cycle consists of projects {A, B}",
projectA);
this.assertMarkers(
"Unexpected markers for project B",
- "A cycle was detected in the build path of project 'B'",
+ "A cycle was detected in the build path of project 'B'. The cycle consists of projects {A, B}",
projectB);
// delete project B
@@ -4384,11 +4384,11 @@
"");
this.assertMarkers(
"Unexpected markers for project A after adding project B back",
- "A cycle was detected in the build path of project 'A'",
+ "A cycle was detected in the build path of project 'A'. The cycle consists of projects {A, B}",
projectA);
this.assertMarkers(
"Unexpected markers for project B after adding project B back",
- "A cycle was detected in the build path of project 'B'",
+ "A cycle was detected in the build path of project 'B'. The cycle consists of projects {A, B}",
projectB);
} finally {
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java
index cfe5273..17cf6b1 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 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
@@ -2423,6 +2423,7 @@
} else {
assertResults(
"interface[KEYWORD]{interface, null, null, interface, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}\n" +
+ "YAAnnot[TYPE_REF]{testxxx.YAAnnot, testxxx, Ltestxxx.YAAnnot;, null, null, " + (R_NAME_PREFIX + R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}\n" +
"_ConfigurationData[TYPE_REF]{test325481._ConfigurationData, test325481, Ltest325481._ConfigurationData;, null, null, " + (R_NAME_PREFIX + R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}\n" +
"_Path[TYPE_REF]{test325481._Path, test325481, Ltest325481._Path;, null, null, " + (R_NAME_PREFIX + R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}\n" +
"Deprecated[TYPE_REF]{Deprecated, java.lang, Ljava.lang.Deprecated;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_TARGET + R_NON_RESTRICTED + R_UNQUALIFIED) + "}\n" +
@@ -9021,6 +9022,7 @@
assertResults(
"interface[KEYWORD]{interface, null, null, interface, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}\n" +
"QQAnnotation[TYPE_REF]{pkgannotations.QQAnnotation, pkgannotations, Lpkgannotations.QQAnnotation;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_TARGET + R_NON_RESTRICTED) + "}\n" +
+ "YAAnnot[TYPE_REF]{testxxx.YAAnnot, testxxx, Ltestxxx.YAAnnot;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_TARGET + R_NON_RESTRICTED) + "}\n" +
"_ConfigurationData[TYPE_REF]{test325481._ConfigurationData, test325481, Ltest325481._ConfigurationData;, null, null, " + (R_NAME_PREFIX + R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}\n" +
"_Path[TYPE_REF]{test325481._Path, test325481, Ltest325481._Path;, null, null, " + (R_NAME_PREFIX + R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}\n" +
"Deprecated[TYPE_REF]{Deprecated, java.lang, Ljava.lang.Deprecated;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_TARGET + R_NON_RESTRICTED + R_UNQUALIFIED) + "}",
@@ -13874,4 +13876,43 @@
"Inn.Inn3[TYPE_REF]{Inn3, label, Llabel.Inn$Inn3;, null, null, 44}",
requestor.getResults());
}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=343865
+// Verify that no NPE is thrown and we get correct proposals
+public void testBug343865a() throws JavaModelException {
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ ICompilationUnit cu = getCompilationUnit("Completion", "src3", "testxxx", "TestType.java");
+
+ String str = cu.getSource();
+ String completeBehind = "@YAAnnot(";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ cu.codeComplete(cursorLocation, requestor);
+
+ assertResults(
+ "name[ANNOTATION_ATTRIBUTE_REF]{name, Ltestxxx.YAAnnot;, Ljava.lang.String;, name, null, " + (R_NAME_FIRST_PREFIX + R_EXPECTED_TYPE + R_RESOLVED) + "}\n" +
+ "val[ANNOTATION_ATTRIBUTE_REF]{val, Ltestxxx.YAAnnot;, I, val, null, " + (R_NAME_FIRST_PREFIX + R_EXPECTED_TYPE + R_RESOLVED) + "}",
+ requestor.getResults());
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=343865
+// Verify that the correct expected type is computed
+public void testBug343865b() throws JavaModelException {
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ ICompilationUnit cu = getCompilationUnit("Completion", "src3", "testxxx", "TestType2.java");
+
+ String str = cu.getSource();
+ String completeBehind = "String xxyy2 = xxy";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ cu.codeComplete(cursorLocation, requestor);
+
+ assertResults(
+ "expectedTypesSignatures={Ljava.lang.String;}\n" +
+ "expectedTypesKeys={Ljava/lang/String;}",
+ requestor.getContext());
+
+ assertResults(
+ "xxyy[FIELD_REF]{xxyy, Ltestxxx.TestType2;, I, xxyy, null, " + (R_NAME_FIRST_PREFIX + R_EXPECTED_TYPE + R_RESOLVED) + "}\n" +
+ "xxyy1[FIELD_REF]{xxyy1, Ltestxxx.TestType2;, Ljava.lang.String;, xxyy1, null, " + (R_NAME_FIRST_PREFIX + R_EXPECTED_TYPE + R_RESOLVED + R_EXACT_EXPECTED_TYPE) + "}",
+ requestor.getResults());
+}
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/OptionTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/OptionTests.java
index 611995e..8793572 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/OptionTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/OptionTests.java
@@ -23,6 +23,7 @@
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.core.JavaModelManager;
import org.eclipse.jdt.internal.core.JavaProject;
@@ -701,4 +702,195 @@
JavaCore.setOptions(wkspOptions);
}
}
+
+/**
+ * @bug 324987: [formatter] API compatibility problem with Annotation Newline options
+ * @test Verify that a deprecated option is well preserved when a client use it
+ * through the IJavaProject.setOption(String, String) API
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=324987"
+ * @deprecated As using deprecated constants
+ */
+public void testBug324987_Project01() throws CoreException {
+ try {
+ // Set the obsolete option using the IJavaProject API
+ JavaProject project = (JavaProject) createJavaProject("P");
+ final String obsoleteOption = DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER;
+ project.setOption(obsoleteOption, JavaCore.DO_NOT_INSERT);
+ // Verify that obsolete preference is not stored
+ assertNull(
+ "Unexpected value for formatter deprecated option 'org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member'",
+ project.getEclipsePreferences().get(obsoleteOption, null));
+ // Verify that project obsolete option is well retrieved
+ assertEquals(
+ "Unexpected value for formatter deprecated option 'org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member'",
+ JavaCore.DO_NOT_INSERT,
+ project.getOption(obsoleteOption, true));
+ } finally {
+ deleteProject("P");
+ }
+}
+/**
+ * @bug 324987: [formatter] API compatibility problem with Annotation Newline options
+ * @test Verify that a new option beats the deprecated option when a client sets both
+ * through the IJavaProject#setOptions(Map) API
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=324987"
+ * @deprecated As using deprecated constants
+ */
+public void testBug324987_Project02() throws CoreException {
+ try {
+ // Set the obsolete option using the IJavaProject API
+ JavaProject project = (JavaProject) createJavaProject("P");
+ final String obsoleteOption = DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER;
+ Map testOptions = project.getOptions(true);
+ testOptions.put(obsoleteOption, JavaCore.DO_NOT_INSERT);
+ project.setOptions(testOptions);
+ // Verify that obsolete preference is not stored
+ assertNull(
+ "Unexpected value for formatter deprecated option 'org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member'",
+ project.getEclipsePreferences().get(obsoleteOption, null));
+ // Verify that project obsolete option is well retrieved
+ assertEquals(
+ "Unexpected value for formatter deprecated option 'org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member'",
+ JavaCore.INSERT,
+ project.getOption(obsoleteOption, true));
+ } finally {
+ deleteProject("P");
+ }
+}
+/**
+ * @bug 324987: [formatter] API compatibility problem with Annotation Newline options
+ * @test Verify that a deprecated option is well preserved when read through
+ * the IEclipsePreferences (i.e. simulate reading project preferences of a project
+ * coming from an older workspace)
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=324987"
+ * @deprecated As using deprecated constants
+ */
+public void testBug324987_Project03() throws CoreException {
+ try {
+ // Set the obsolete preference simulating a project coming from an older version workspace
+ JavaProject project = (JavaProject) createJavaProject("P");
+ final String obsoleteOption = DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER;
+ project.getEclipsePreferences().put(obsoleteOption, JavaCore.DO_NOT_INSERT);
+ // Verify that obsolete preference is stored
+ assertEquals(
+ "Unexpected value for formatter deprecated option 'org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member'",
+ JavaCore.DO_NOT_INSERT,
+ project.getEclipsePreferences().get(obsoleteOption, null));
+ // Verify that project obsolete option is well retrieved
+ assertEquals(
+ "Unexpected value for formatter deprecated option 'org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member'",
+ JavaCore.DO_NOT_INSERT,
+ project.getOption(obsoleteOption, true));
+ } finally {
+ deleteProject("P");
+ }
+}
+/**
+ * @bug 324987: [formatter] API compatibility problem with Annotation Newline options
+ * @test Verify that a new option beats the deprecated option when a client sets both
+ * through the JavaCore.setOptions(Hashtable) API
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=324987"
+ * @deprecated As using deprecated constants
+ */
+public void testBug324987_Workspace01() throws CoreException {
+ try {
+ // Set the obsolete option using the JavaCore API
+ final String obsoleteOption = DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER;
+ Hashtable testOptions = JavaCore.getOptions();
+ testOptions.put(obsoleteOption, JavaCore.DO_NOT_INSERT);
+ JavaCore.setOptions(testOptions);
+ // Verify that obsolete preference is not stored
+ assertNull(
+ "Unexpected value for formatter deprecated option 'org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member'",
+ JavaModelManager.getJavaModelManager().getInstancePreferences().get(obsoleteOption, null));
+ // Verify that workspace obsolete option is well retrieved
+ assertEquals(
+ "Unexpected value for formatter deprecated option 'org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member'",
+ JavaCore.INSERT,
+ JavaCore.getOption(obsoleteOption));
+ } finally {
+ JavaCore.setOptions(JavaCore.getDefaultOptions());
+ }
+}
+/**
+ * @bug 324987: [formatter] API compatibility problem with Annotation Newline options
+ * @test Verify that a deprecated option is well preserved when read through
+ * the IEclipsePreferences (i.e. simulate reading an older workspace)
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=324987"
+ * @deprecated As using deprecated constants
+ */
+public void testBug324987_Workspace02() throws CoreException {
+ try {
+ // Set the obsolete preference simulating an older version workspace
+ final String obsoleteOption = DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER;
+ IEclipsePreferences instancePreferences = JavaModelManager.getJavaModelManager().getInstancePreferences();
+ instancePreferences.put(obsoleteOption, JavaCore.DO_NOT_INSERT);
+ // Verify that obsolete preference is stored
+ assertEquals(
+ "Unexpected value for formatter deprecated option 'org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member'",
+ JavaCore.DO_NOT_INSERT,
+ instancePreferences.get(obsoleteOption, null));
+ // Verify that project obsolete option is well retrieved
+ assertEquals(
+ "Unexpected value for formatter deprecated option 'org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member'",
+ JavaCore.DO_NOT_INSERT,
+ JavaCore.getOption(obsoleteOption));
+ } finally {
+ deleteProject("P");
+ }
+}
+/**
+ * @bug 324987: [formatter] API compatibility problem with Annotation Newline options
+ * @test Verify that a deprecated option is well preserved when a client use it
+ * through the JavaCore.setOptions(Hashtable) API
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=324987"
+ * @deprecated As using deprecated constants
+ */
+public void testBug324987_Workspace03() throws CoreException {
+ try {
+ // Set the obsolete option using the JavaCore API
+ final String obsoleteOption = DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER;
+ Hashtable testOptions = JavaCore.getOptions();
+ testOptions.put(obsoleteOption, JavaCore.INSERT);
+ JavaCore.setOptions(testOptions);
+ // Verify that obsolete preference is not stored
+ assertNull(
+ "Unexpected value for formatter deprecated option 'org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member'",
+ JavaModelManager.getJavaModelManager().getInstancePreferences().get(obsoleteOption, null));
+ // Verify that workspace obsolete option is well retrieved
+ assertEquals(
+ "Unexpected value for formatter deprecated option 'org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member'",
+ JavaCore.INSERT,
+ JavaCore.getOption(obsoleteOption));
+ } finally {
+ JavaCore.setOptions(JavaCore.getDefaultOptions());
+ }
+}
+/**
+ * @bug 324987: [formatter] API compatibility problem with Annotation Newline options
+ * @test Verify that a deprecated option is well preserved when read through
+ * the IEclipsePreferences (i.e. simulate reading an older workspace)
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=324987"
+ * @deprecated As using deprecated constants
+ */
+public void testBug324987_Workspace04() throws CoreException {
+ try {
+ // Set the obsolete preference simulating an older version workspace
+ final String obsoleteOption = DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER;
+ IEclipsePreferences instancePreferences = JavaModelManager.getJavaModelManager().getInstancePreferences();
+ instancePreferences.put(obsoleteOption, JavaCore.INSERT);
+ // Verify that obsolete preference is stored
+ assertEquals(
+ "Unexpected value for formatter deprecated option 'org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member'",
+ JavaCore.INSERT,
+ instancePreferences.get(obsoleteOption, null));
+ // Verify that project obsolete option is well retrieved
+ assertEquals(
+ "Unexpected value for formatter deprecated option 'org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member'",
+ JavaCore.INSERT,
+ JavaCore.getOption(obsoleteOption));
+ } finally {
+ deleteProject("P");
+ }
+}
}