Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 195218 Details for
Bug 324987
[formatter] API compatibility problem with Annotation Newline options
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Fix 4
324987_patch4.txt (text/plain), 43.29 KB, created by
Markus Keller
on 2011-05-10 10:15:55 EDT
(
hide
)
Description:
Fix 4
Filename:
MIME Type:
Creator:
Markus Keller
Created:
2011-05-10 10:15:55 EDT
Size:
43.29 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java,v >retrieving revision 1.110 >diff -u -r1.110 DefaultCodeFormatterOptions.java >--- formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java 20 Jan 2011 15:31:08 -0000 1.110 >+++ formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java 10 May 2011 14:14:40 -0000 >@@ -2041,47 +2041,69 @@ > this.comment_clear_blank_lines_in_block_comment = DefaultCodeFormatterConstants.TRUE.equals(commentClearBlankLinesInBlockCommentOption); > } > } >+ > // New line after annotations > final Object insertNewLineAfterAnnotationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION); >- if (insertNewLineAfterAnnotationOption != null) { // check if deprecated 3.1 option was used >- boolean insert = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOption); >- this.insert_new_line_after_annotation_on_type = insert; >- this.insert_new_line_after_annotation_on_field = insert; >- this.insert_new_line_after_annotation_on_method = insert; >- this.insert_new_line_after_annotation_on_package = insert; >- this.insert_new_line_after_annotation_on_parameter = insert; >- this.insert_new_line_after_annotation_on_local_variable = insert; >- } else { >- final Object insertNewLineAfterAnnotationOnMemberOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER); >- if (insertNewLineAfterAnnotationOnMemberOption != null) { // check if deprecated 3.4 option was used >+ >+ final Object insertNewLineAfterAnnotationOnMemberOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER); >+ final Object insertNewLineAfterAnnotationOnTypeOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE); >+ final Object insertNewLineAfterAnnotationOnFieldOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD); >+ final Object insertNewLineAfterAnnotationOnMethodOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD); >+ final Object insertNewLineAfterAnnotationOnPackageOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE); >+ >+ final Object insertNewLineAfterAnnotationOnParameterOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER); >+ final Object insertNewLineAfterAnnotationOnLocalVariableOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE); >+ >+ if (insertNewLineAfterAnnotationOnTypeOption == null >+ && insertNewLineAfterAnnotationOnFieldOption == null >+ && insertNewLineAfterAnnotationOnMethodOption == null >+ && insertNewLineAfterAnnotationOnPackageOption == null) { >+ // if none of the new 3.7 options is used, fall back to the deprecated 3.4 option >+ if (insertNewLineAfterAnnotationOnMemberOption != null) { > boolean insert = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOnMemberOption); > this.insert_new_line_after_annotation_on_type = insert; > this.insert_new_line_after_annotation_on_field = insert; > this.insert_new_line_after_annotation_on_method = insert; > this.insert_new_line_after_annotation_on_package = insert; >- } else { // otherwise use new options >- final Object insertNewLineAfterAnnotationOnTypeOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE); >- if (insertNewLineAfterAnnotationOnTypeOption != null) { >- this.insert_new_line_after_annotation_on_type = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOnTypeOption); >- } >- final Object insertNewLineAfterAnnotationOnFieldOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD); >- if (insertNewLineAfterAnnotationOnFieldOption != null) { >- this.insert_new_line_after_annotation_on_field = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOnFieldOption); >+ >+ // and use the other 3.4 options if available >+ if (insertNewLineAfterAnnotationOnParameterOption != null) { >+ this.insert_new_line_after_annotation_on_parameter = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOnParameterOption); > } >- final Object insertNewLineAfterAnnotationOnMethodOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD); >- if (insertNewLineAfterAnnotationOnMethodOption != null) { >- this.insert_new_line_after_annotation_on_method = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOnMethodOption); >+ if (insertNewLineAfterAnnotationOnLocalVariableOption != null) { >+ this.insert_new_line_after_annotation_on_local_variable = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOnLocalVariableOption); > } >- final Object insertNewLineAfterAnnotationOnPackageOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE); >- if (insertNewLineAfterAnnotationOnPackageOption != null) { >- this.insert_new_line_after_annotation_on_package = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOnPackageOption); >+ >+ } else if (insertNewLineAfterAnnotationOnParameterOption == null >+ && insertNewLineAfterAnnotationOnLocalVariableOption == null) { >+ // if none of the new 3.4 options is used, fall back to the deprecated 3.1 option >+ if (insertNewLineAfterAnnotationOption != null) { >+ boolean insert = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOption); >+ this.insert_new_line_after_annotation_on_type = insert; >+ this.insert_new_line_after_annotation_on_field = insert; >+ this.insert_new_line_after_annotation_on_method = insert; >+ this.insert_new_line_after_annotation_on_package = insert; >+ this.insert_new_line_after_annotation_on_parameter = insert; >+ this.insert_new_line_after_annotation_on_local_variable = insert; > } > } >- final Object insertNewLineAfterAnnotationOnParameterOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER); >+ } else { // otherwise use new 3.7 options if available >+ if (insertNewLineAfterAnnotationOnTypeOption != null) { >+ this.insert_new_line_after_annotation_on_type = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOnTypeOption); >+ } >+ if (insertNewLineAfterAnnotationOnFieldOption != null) { >+ this.insert_new_line_after_annotation_on_field = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOnFieldOption); >+ } >+ if (insertNewLineAfterAnnotationOnMethodOption != null) { >+ this.insert_new_line_after_annotation_on_method = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOnMethodOption); >+ } >+ if (insertNewLineAfterAnnotationOnPackageOption != null) { >+ this.insert_new_line_after_annotation_on_package = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOnPackageOption); >+ } >+ // and the other 3.4 options if available > if (insertNewLineAfterAnnotationOnParameterOption != null) { > this.insert_new_line_after_annotation_on_parameter = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOnParameterOption); > } >- final Object insertNewLineAfterAnnotationOnLocalVariableOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE); > if (insertNewLineAfterAnnotationOnLocalVariableOption != null) { > this.insert_new_line_after_annotation_on_local_variable = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOnLocalVariableOption); > } >Index: model/org/eclipse/jdt/internal/core/JavaCorePreferenceInitializer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaCorePreferenceInitializer.java,v >retrieving revision 1.49 >diff -u -r1.49 JavaCorePreferenceInitializer.java >--- model/org/eclipse/jdt/internal/core/JavaCorePreferenceInitializer.java 6 Jan 2011 13:43:57 -0000 1.49 >+++ model/org/eclipse/jdt/internal/core/JavaCorePreferenceInitializer.java 10 May 2011 14:14:40 -0000 >@@ -101,5 +101,31 @@ > defaultPreferences.put(optionName, (String)entry.getValue()); > optionNames.add(optionName); > } >+ >+ // Initialize deprecated options >+ initializeDeprecatedOptions(); >+ } >+ >+ /** >+ * @deprecated As using deprecated options >+ */ >+ private void initializeDeprecatedOptions() { >+ Map deprecatedOptions = JavaModelManager.getJavaModelManager().deprecatedOptions; >+ deprecatedOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER, >+ new String[] { >+ DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD, >+ DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD, >+ DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE, >+ DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE >+ }); >+ deprecatedOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION, >+ new String[] { >+ DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD, >+ DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD, >+ DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE, >+ DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE, >+ DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, >+ DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER >+ }); > } > } >Index: model/org/eclipse/jdt/internal/core/JavaModelManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java,v >retrieving revision 1.466 >diff -u -r1.466 JavaModelManager.java >--- model/org/eclipse/jdt/internal/core/JavaModelManager.java 3 Apr 2011 19:07:01 -0000 1.466 >+++ model/org/eclipse/jdt/internal/core/JavaModelManager.java 10 May 2011 14:14:40 -0000 >@@ -270,10 +270,15 @@ > > public final static ICompilationUnit[] NO_WORKING_COPY = new ICompilationUnit[0]; > >- // Preferences >+ // Options >+ private final static int UNKNOWN_OPTION = 0; >+ private final static int DEPRECATED_OPTION = 1; >+ private final static int VALID_OPTION = 2; > HashSet optionNames = new HashSet(20); >+ Map deprecatedOptions = new HashMap(); > Hashtable optionsCache; > >+ // Preferences > public final IEclipsePreferences[] preferencesLookup = new IEclipsePreferences[2]; > static final int PREF_INSTANCE = 0; > static final int PREF_DEFAULT = 1; >@@ -2057,15 +2062,91 @@ > if (isDeprecatedOption(optionName)) { > return JavaCore.ERROR; > } >- String propertyName = optionName; >- if (this.optionNames.contains(propertyName)){ >+ int optionLevel = getOptionLevel(optionName); >+ if (optionLevel != UNKNOWN_OPTION){ > IPreferencesService service = Platform.getPreferencesService(); >- String value = service.get(optionName, null, this.preferencesLookup); >+ String value = service.get(optionName, null, this.preferencesLookup); >+ if (value == null && optionLevel == DEPRECATED_OPTION) { >+ // May be a deprecated option, retrieve the new value in compatible options >+ String[] compatibleOptions = (String[]) this.deprecatedOptions.get(optionName); >+ value = service.get(compatibleOptions[0], null, this.preferencesLookup); >+ } > return value==null ? null : value.trim(); > } > return null; > } > >+ /** >+ * Returns the value of the given option for the given Eclipse preferences. >+ * If no value was already set, then inherits from the global options if specified. >+ * >+ * @param optionName The name of the option >+ * @param inheritJavaCoreOptions Tells whether the value can be inherited from global JavaCore options >+ * @param projectPreferences The eclipse preferences from which to get the value >+ * @return The value of the option. May be <code>null</code> >+ */ >+ public String getOption(String optionName, boolean inheritJavaCoreOptions, IEclipsePreferences projectPreferences) { >+ // Return the option value depending on its level >+ switch (getOptionLevel(optionName)) { >+ case VALID_OPTION: >+ // Valid option, return the preference value >+ String javaCoreDefault = inheritJavaCoreOptions ? JavaCore.getOption(optionName) : null; >+ if (projectPreferences == null) return javaCoreDefault; >+ String value = projectPreferences.get(optionName, javaCoreDefault); >+ return value == null ? null : value.trim(); >+ case DEPRECATED_OPTION: >+ // Return the deprecated option value if it was already set >+ String oldValue = projectPreferences.get(optionName, null); >+ if (oldValue != null) { >+ return oldValue.trim(); >+ } >+ // Get the new compatible value >+ String[] compatibleOptions = (String[]) this.deprecatedOptions.get(optionName); >+ String newDefault = inheritJavaCoreOptions ? JavaCore.getOption(compatibleOptions[0]) : null; >+ String newValue = projectPreferences.get(compatibleOptions[0], newDefault); >+ return newValue == null ? null : newValue.trim(); >+ } >+ return null; >+ } >+ >+ /** >+ * Returns whether an option name is known or not. >+ * >+ * @param optionName The name of the option >+ * @return <code>true</code> when the option name is either >+ * {@link #VALID_OPTION valid} or {@link #DEPRECATED_OPTION deprecated}, >+ * <code>false</code> otherwise. >+ */ >+ public boolean knowsOption(String optionName) { >+ boolean knownOption = this.optionNames.contains(optionName); >+ if (!knownOption) { >+ knownOption = this.deprecatedOptions.get(optionName) != null; >+ } >+ return knownOption; >+ } >+ >+ /** >+ * Returns the level of the given option. >+ * >+ * @param optionName The name of the option >+ * @return The level of the option as an int which may have the following >+ * values: >+ * <ul> >+ * <li>{@link #UNKNOWN_OPTION}: the given option is unknown</li> >+ * <li>{@link #DEPRECATED_OPTION}: the given option is deprecated</li> >+ * <li>{@link #VALID_OPTION}: the given option is valid</li> >+ * </ul> >+ */ >+ public int getOptionLevel(String optionName) { >+ if (this.optionNames.contains(optionName)) { >+ return VALID_OPTION; >+ } >+ if (this.deprecatedOptions.get(optionName) != null) { >+ return DEPRECATED_OPTION; >+ } >+ return UNKNOWN_OPTION; >+ } >+ > public Hashtable getOptions() { > > // return cached options if already computed >@@ -2095,21 +2176,28 @@ > } > if (DEBUG_302850) checkTaskTags("Options initialized from preferences", options); //$NON-NLS-1$ > >+ // set deprecated options using preferences service lookup >+ Iterator deprecatedEntries = this.deprecatedOptions.entrySet().iterator(); >+ while (deprecatedEntries.hasNext()) { >+ Entry entry = (Entry) deprecatedEntries.next(); >+ String propertyName = (String) entry.getKey(); >+ String propertyValue = service.get(propertyName, null, this.preferencesLookup); >+ if (propertyValue != null) { >+ options.put(propertyName, propertyValue); >+ String[] compatibleOptions = (String[]) entry.getValue(); >+ for (int co=0, length=compatibleOptions.length; co < length; co++) { >+ String compatibleOption = compatibleOptions[co]; >+ if (!options.containsKey(compatibleOption)) >+ options.put(compatibleOption, propertyValue); >+ } >+ } >+ } >+ > // get encoding through resource plugin > options.put(JavaCore.CORE_ENCODING, JavaCore.getEncoding()); > > // backward compatibility > addDeprecatedOptions(options); >- try { >- final IEclipsePreferences eclipsePreferences = this.preferencesLookup[PREF_INSTANCE]; >- String[] instanceKeys = eclipsePreferences.keys(); >- for (int i=0, length=instanceKeys.length; i<length; i++) { >- String optionName = instanceKeys[i]; >- migrateObsoleteOption(options, optionName, eclipsePreferences.get(optionName, null)); >- } >- } catch (BackingStoreException e) { >- // skip >- } > > Util.fixTaskTags(options); > if (DEBUG_302850) checkTaskTags("Retrieved options from preferences", options); //$NON-NLS-1$ >@@ -2136,63 +2224,6 @@ > } > } > >- /** >- * Migrates an old option value to its new corresponding option name(s) >- * when necessary. >- * <p> >- * Nothing is done if the given option is not obsolete or if no migration has been >- * specified for it. >- * </p><p> >- * Currently, migration is only done for formatter options. >- * </p> >- * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=308000" >- * >- * @param options The options map to update >- * @param optionName The old option name to update >- * @param optionValue The value of the old option name >- */ >- public void migrateObsoleteOption(Map options, String optionName, String optionValue) { >- >- // Migrate formatter options >- String[] compatibleConstants = getFormatterCompatibleConstants(optionName); >- if (compatibleConstants != null) { >- for (int i=0, length=compatibleConstants.length; i < length; i++) { >- options.put(compatibleConstants[i], optionValue); >- } >- return; >- } >- } >- >- /** >- * Return an array of compatible constants for an obsolete constant. >- * >- * @param name The name of the obsolete constant >- * @return The list as a non-empty array of the compatible constants or >- * <code>null</code> if the constant is <b>not</b> obsolete. >- * @deprecated As using deprecated formatter constants >- */ >- private static String[] getFormatterCompatibleConstants(String name) { >- if (DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER.equals(name)) { >- return new String[] { >- DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD, >- DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD, >- DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE, >- DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE >- }; >- } >- if (DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION.equals(name)) { >- return new String[] { >- DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD, >- DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD, >- DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE, >- DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE, >- DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, >- DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER >- }; >- } >- return null; >- } >- > // Do not modify without modifying getDefaultOptions() > private Hashtable getDefaultOptionsNoInitialization() { > Map defaultOptionsMap = new CompilerOptions().getMap(); // compiler defaults >@@ -4750,6 +4781,47 @@ > } > } > >+ /** >+ * Store the preferences value for the given option name. >+ * >+ * @param optionName The name of the option >+ * @param optionValue The value of the option. If <code>null</code>, then >+ * the option will be removed from the preferences instead. >+ * @param eclipsePreferences The eclipse preferences to be updated >+ * @return <code>true</code> if the preferences have been changed, >+ * <code>false</code> otherwise. >+ */ >+ public boolean storePreference(String optionName, String optionValue, IEclipsePreferences eclipsePreferences) { >+ int optionLevel = this.getOptionLevel(optionName); >+ if (optionLevel == UNKNOWN_OPTION) return false; // unrecognized option >+ >+ // Store option value >+ switch (optionLevel) { >+ case JavaModelManager.VALID_OPTION: >+ if (optionValue == null) { >+ eclipsePreferences.remove(optionName); >+ } else { >+ eclipsePreferences.put(optionName, optionValue); >+ } >+ break; >+ case JavaModelManager.DEPRECATED_OPTION: >+ // Try to migrate deprecated option >+ eclipsePreferences.remove(optionName); // get rid off old preference >+ String[] compatibleOptions = (String[]) this.deprecatedOptions.get(optionName); >+ for (int co=0, length=compatibleOptions.length; co < length; co++) { >+ if (optionValue == null) { >+ eclipsePreferences.remove(compatibleOptions[co]); >+ } else { >+ eclipsePreferences.put(compatibleOptions[co], optionValue); >+ } >+ } >+ break; >+ default: >+ return false; >+ } >+ return true; >+ } >+ > public void setOptions(Hashtable newOptions) { > > if (DEBUG_302850) { >@@ -4776,20 +4848,21 @@ > Enumeration keys = newOptions.keys(); > while (keys.hasMoreElements()){ > String key = (String)keys.nextElement(); >- if (!this.optionNames.contains(key)) continue; // unrecognized option >+ int optionLevel = getOptionLevel(key); >+ if (optionLevel == UNKNOWN_OPTION) continue; // unrecognized option > if (key.equals(JavaCore.CORE_ENCODING)) { > if (cachedValue != null) { > cachedValue.put(key, JavaCore.getEncoding()); > } > continue; // skipped, contributed by resource prefs > } >- String value = (String)newOptions.get(key); >+ String value = (String) newOptions.get(key); > String defaultValue = defaultPreferences.get(key, null); >+ // Store value in preferences > if (defaultValue != null && defaultValue.equals(value)) { >- instancePreferences.remove(key); >- } else { >- instancePreferences.put(key, value); >+ value = null; > } >+ storePreference(key, value, instancePreferences); > } > try { > // persist options >Index: model/org/eclipse/jdt/internal/core/JavaProject.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java,v >retrieving revision 1.446 >diff -u -r1.446 JavaProject.java >--- model/org/eclipse/jdt/internal/core/JavaProject.java 4 May 2011 14:47:29 -0000 1.446 >+++ model/org/eclipse/jdt/internal/core/JavaProject.java 10 May 2011 14:14:40 -0000 >@@ -1635,14 +1635,7 @@ > * @see org.eclipse.jdt.core.IJavaProject#getOption(String, boolean) > */ > public String getOption(String optionName, boolean inheritJavaCoreOptions) { >- if (JavaModelManager.getJavaModelManager().optionNames.contains(optionName)){ >- IEclipsePreferences projectPreferences = getEclipsePreferences(); >- String javaCoreDefault = inheritJavaCoreOptions ? JavaCore.getOption(optionName) : null; >- if (projectPreferences == null) return javaCoreDefault; >- String value = projectPreferences.get(optionName, javaCoreDefault); >- return value == null ? null : value.trim(); >- } >- return null; >+ return JavaModelManager.getJavaModelManager().getOption(optionName, inheritJavaCoreOptions, getEclipsePreferences()); > } > > /** >@@ -1672,11 +1665,20 @@ > String propertyName = propertyNames[i]; > String value = projectPreferences.get(propertyName, null); > if (value != null) { >- if (optionNames.contains(propertyName)){ >- projectOptions.put(propertyName, value.trim()); >- } else { >- // Maybe an obsolete preference, try to migrate it... >- javaModelManager.migrateObsoleteOption(projectOptions, propertyName, value.trim()); >+ value = value.trim(); >+ // Keep the option value, even if it's deprecated >+ // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=324987 >+ projectOptions.put(propertyName, value); >+ if (!optionNames.contains(propertyName)) { >+ // try to migrate deprecated options >+ String[] compatibleOptions = (String[]) javaModelManager.deprecatedOptions.get(propertyName); >+ if (compatibleOptions != null) { >+ for (int co=0, length=compatibleOptions.length; co < length; co++) { >+ String compatibleOption = compatibleOptions[co]; >+ if (!projectOptions.containsKey(compatibleOption)) >+ projectOptions.put(compatibleOption, value); >+ } >+ } > } > } > } >@@ -1696,7 +1698,7 @@ > Map.Entry entry = (Map.Entry) propertyNames.next(); > String propertyName = (String) entry.getKey(); > String propertyValue = (String) entry.getValue(); >- if (propertyValue != null && optionNames.contains(propertyName)){ >+ if (propertyValue != null && javaModelManager.knowsOption(propertyName)){ > options.put(propertyName, propertyValue.trim()); > } > } >@@ -2924,20 +2926,17 @@ > * @see org.eclipse.jdt.core.IJavaProject#setOption(java.lang.String, java.lang.String) > */ > public void setOption(String optionName, String optionValue) { >- if (!JavaModelManager.getJavaModelManager().optionNames.contains(optionName)) return; // unrecognized option >+ // Store option value > IEclipsePreferences projectPreferences = getEclipsePreferences(); >- if (optionValue == null) { >- // remove preference >- projectPreferences.remove(optionName); >- } else { >- projectPreferences.put(optionName, optionValue); >- } >+ boolean modified = JavaModelManager.getJavaModelManager().storePreference(optionName, optionValue, projectPreferences); > >- // Dump changes >- try { >- projectPreferences.flush(); >- } catch (BackingStoreException e) { >- // problem with pref store - quietly ignore >+ // Write changes >+ if (modified) { >+ try { >+ projectPreferences.flush(); >+ } catch (BackingStoreException e) { >+ // problem with pref store - quietly ignore >+ } > } > } > >@@ -2953,12 +2952,12 @@ > projectPreferences.clear(); > } else { > Iterator entries = newOptions.entrySet().iterator(); >+ JavaModelManager javaModelManager = JavaModelManager.getJavaModelManager(); > while (entries.hasNext()){ > Map.Entry entry = (Map.Entry) entries.next(); > String key = (String) entry.getKey(); >- if (!JavaModelManager.getJavaModelManager().optionNames.contains(key)) continue; // unrecognized option >- // no filtering for encoding (custom encoding for project is allowed) >- projectPreferences.put(key, (String) entry.getValue()); >+ String value = (String) entry.getValue(); >+ javaModelManager.storePreference(key, value, projectPreferences); > } > > // reset to default all options not in new map >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java,v >retrieving revision 1.265 >diff -u -r1.265 FormatterRegressionTests.java >--- src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java 14 Feb 2011 17:46:55 -0000 1.265 >+++ src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java 10 May 2011 14:14:27 -0000 >@@ -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" + >Index: src/org/eclipse/jdt/core/tests/model/OptionTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/OptionTests.java,v >retrieving revision 1.31 >diff -u -r1.31 OptionTests.java >--- src/org/eclipse/jdt/core/tests/model/OptionTests.java 7 Jan 2011 20:47:00 -0000 1.31 >+++ src/org/eclipse/jdt/core/tests/model/OptionTests.java 10 May 2011 14:14:27 -0000 >@@ -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"); >+ } >+} > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 324987
:
178758
|
178760
|
195065
|
195105
| 195218