/** * @param options the options to add to this options */ public void addAll(CleanUpOptions options) { if (options instanceof MapCleanUpOptions) { fOptions.putAll(((MapCleanUpOptions)options).getMap()); } else { Set<String> keys= options.getKeys(); for (Iterator<String> iterator= keys.iterator(); iterator.hasNext();) { String key= iterator.next(); fOptions.put(key, options.getValue(key)); } } }
/** * @param key the name of the option * @return <code>true</code> if option with <code>key</code> is enabled */ protected boolean isEnabled(String key) { Assert.isNotNull(fOptions); Assert.isLegal(key != null); return fOptions.isEnabled(key); }
options.setOption(MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS, CleanUpOptions.FALSE); options.setOption(MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_ALWAYS, CleanUpOptions.FALSE); options.setOption(MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_IF_NECESSARY, CleanUpOptions.TRUE); options.setOption(MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS, CleanUpOptions.FALSE); options.setOption(MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS_ALWAYS, CleanUpOptions.FALSE); options.setOption(MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS_IF_NECESSARY, CleanUpOptions.TRUE); options.setOption(MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS, CleanUpOptions.FALSE); options.setOption(MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_FIELD, CleanUpOptions.FALSE); options.setOption(MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_METHOD, CleanUpOptions.FALSE); options.setOption(MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_SUBTYPE_ACCESS, CleanUpOptions.TRUE); options.setOption(MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_INSTANCE_ACCESS, CleanUpOptions.TRUE); options.setOption(CONTROL_STATEMENTS_USE_BLOCKS, CleanUpOptions.FALSE); options.setOption(CONTROL_STATMENTS_USE_BLOCKS_ALWAYS, CleanUpOptions.TRUE); options.setOption(CONTROL_STATMENTS_USE_BLOCKS_NO_FOR_RETURN_AND_THROW, CleanUpOptions.FALSE); options.setOption(CONTROL_STATMENTS_USE_BLOCKS_NEVER, CleanUpOptions.FALSE); options.setOption(CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED, CleanUpOptions.FALSE); options.setOption(EXPRESSIONS_USE_PARENTHESES, CleanUpOptions.FALSE); options.setOption(EXPRESSIONS_USE_PARENTHESES_NEVER, CleanUpOptions.TRUE); options.setOption(EXPRESSIONS_USE_PARENTHESES_ALWAYS, CleanUpOptions.FALSE); options.setOption(VARIABLE_DECLARATIONS_USE_FINAL, CleanUpOptions.FALSE); options.setOption(VARIABLE_DECLARATIONS_USE_FINAL_LOCAL_VARIABLES, CleanUpOptions.TRUE); options.setOption(VARIABLE_DECLARATIONS_USE_FINAL_PARAMETERS, CleanUpOptions.FALSE); options.setOption(VARIABLE_DECLARATIONS_USE_FINAL_PRIVATE_FIELDS, CleanUpOptions.TRUE);
disable[0]= true; else { cleanUp.setOptions(new CleanUpOptions()); String[] enbledSteps= cleanUp.getStepDescriptions(); if (enbledSteps != null && enbledSteps.length > 0) {
private static void updateFrom1To2(Map<String, String> settings) { CleanUpOptions defaultSettings= JavaPlugin.getDefault().getCleanUpRegistry().getDefaultOptions(CleanUpConstants.DEFAULT_CLEAN_UP_OPTIONS); settings.put(CleanUpConstants.ORGANIZE_IMPORTS, defaultSettings.getValue(CleanUpConstants.ORGANIZE_IMPORTS)); }
disable[0]= true; else { cleanUp.setOptions(new CleanUpOptions()); String[] enbledSteps= cleanUp.getStepDescriptions(); if (enbledSteps != null && enbledSteps.length > 0) {
private static void updateFrom1To2(Map<String, String> settings) { CleanUpOptions defaultSettings= JavaPlugin.getDefault().getCleanUpRegistry().getDefaultOptions(CleanUpConstants.DEFAULT_CLEAN_UP_OPTIONS); settings.put(CleanUpConstants.ORGANIZE_IMPORTS, defaultSettings.getValue(CleanUpConstants.ORGANIZE_IMPORTS)); }
/** * @param options the options to add to this options */ public void addAll(CleanUpOptions options) { if (options instanceof MapCleanUpOptions) { fOptions.putAll(((MapCleanUpOptions)options).getMap()); } else { Set<String> keys= options.getKeys(); for (Iterator<String> iterator= keys.iterator(); iterator.hasNext();) { String key= iterator.next(); fOptions.put(key, options.getValue(key)); } } }
options.setOption(MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS, CleanUpOptions.FALSE); options.setOption(MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_ALWAYS, CleanUpOptions.FALSE); options.setOption(MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_IF_NECESSARY, CleanUpOptions.TRUE); options.setOption(MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS, CleanUpOptions.FALSE); options.setOption(MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS_ALWAYS, CleanUpOptions.FALSE); options.setOption(MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS_IF_NECESSARY, CleanUpOptions.TRUE); options.setOption(MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS, CleanUpOptions.TRUE); options.setOption(MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_FIELD, CleanUpOptions.FALSE); options.setOption(MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_METHOD, CleanUpOptions.FALSE); options.setOption(MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_SUBTYPE_ACCESS, CleanUpOptions.TRUE); options.setOption(MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_INSTANCE_ACCESS, CleanUpOptions.TRUE); options.setOption(CONTROL_STATEMENTS_USE_BLOCKS, CleanUpOptions.FALSE); options.setOption(CONTROL_STATMENTS_USE_BLOCKS_ALWAYS, CleanUpOptions.TRUE); options.setOption(CONTROL_STATMENTS_USE_BLOCKS_NO_FOR_RETURN_AND_THROW, CleanUpOptions.FALSE); options.setOption(CONTROL_STATMENTS_USE_BLOCKS_NEVER, CleanUpOptions.FALSE); options.setOption(CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED, CleanUpOptions.FALSE); options.setOption(EXPRESSIONS_USE_PARENTHESES, CleanUpOptions.FALSE); options.setOption(EXPRESSIONS_USE_PARENTHESES_NEVER, CleanUpOptions.TRUE); options.setOption(EXPRESSIONS_USE_PARENTHESES_ALWAYS, CleanUpOptions.FALSE); options.setOption(VARIABLE_DECLARATIONS_USE_FINAL, CleanUpOptions.FALSE); options.setOption(VARIABLE_DECLARATIONS_USE_FINAL_LOCAL_VARIABLES, CleanUpOptions.TRUE); options.setOption(VARIABLE_DECLARATIONS_USE_FINAL_PARAMETERS, CleanUpOptions.FALSE); options.setOption(VARIABLE_DECLARATIONS_USE_FINAL_PRIVATE_FIELDS, CleanUpOptions.TRUE);
/** * Returns the default options for the specified clean up kind. * * @param kind the kind of clean up for which to retrieve the options * @return the default options * * @see CleanUpConstants#DEFAULT_CLEAN_UP_OPTIONS * @see CleanUpConstants#DEFAULT_SAVE_ACTION_OPTIONS */ public MapCleanUpOptions getDefaultOptions(int kind) { ensureCleanUpInitializersRegistered(); CleanUpOptions options= new CleanUpOptions(); for (int i= 0; i < fCleanUpInitializerDescriptors.length; i++) { CleanUpInitializerDescriptor descriptor= fCleanUpInitializerDescriptors[i]; if (descriptor.getKind() == kind) { descriptor.getOptionsInitializer().setDefaultOptions(options); } } MapCleanUpOptions mapCleanUpOptions= new MapCleanUpOptions(); mapCleanUpOptions.addAll(options); return mapCleanUpOptions; }
private static Map<String, String> loadFromProject(IScopeContext context) { final Map<String, String> profileOptions= new HashMap<>(); IEclipsePreferences uiPrefs= context.getNode(JavaUI.ID_PLUGIN); CleanUpProfileVersioner versioner= new CleanUpProfileVersioner(); CleanUpOptions defaultOptions= JavaPlugin.getDefault().getCleanUpRegistry().getDefaultOptions(CleanUpConstants.DEFAULT_CLEAN_UP_OPTIONS); KeySet[] keySets= CleanUpProfileManager.KEY_SETS; boolean hasValues= false; for (int i= 0; i < keySets.length; i++) { KeySet keySet= keySets[i]; IEclipsePreferences preferences= context.getNode(keySet.getNodeName()); for (final Iterator<String> keyIter = keySet.getKeys().iterator(); keyIter.hasNext(); ) { final String key= keyIter.next(); String val= preferences.get(key, null); if (val != null) { hasValues= true; } else { val= defaultOptions.getValue(key); } profileOptions.put(key, val); } } if (!hasValues) return null; int version= uiPrefs.getInt(CleanUpConstants.CLEANUP_SETTINGS_VERSION_KEY, versioner.getFirstVersion()); if (version == versioner.getCurrentVersion()) return profileOptions; CustomProfile profile= new CustomProfile("tmp", profileOptions, version, versioner.getProfileKind()); //$NON-NLS-1$ versioner.update(profile); return profile.getSettings(); }
/** * @param key the name of the option * @return <code>true</code> if option with <code>key</code> is enabled */ protected boolean isEnabled(String key) { Assert.isNotNull(fOptions); Assert.isLegal(key != null); return fOptions.isEnabled(key); }
public static void initDefaults(IPreferenceStore store) { CleanUpOptions settings= JavaPlugin.getDefault().getCleanUpRegistry().getDefaultOptions(CleanUpConstants.DEFAULT_CLEAN_UP_OPTIONS); for (Iterator<String> iterator= settings.getKeys().iterator(); iterator.hasNext();) { String key= iterator.next(); store.setDefault(key, settings.getValue(key)); } store.setDefault(SHOW_CLEAN_UP_WIZARD, true); store.setDefault(CLEANUP_PROFILE, DEFAULT_PROFILE); store.setDefault(CLEANUP_ON_SAVE_PROFILE, DEFAULT_SAVE_PARTICIPANT_PROFILE); }
options.setOption(MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS, CleanUpOptions.FALSE); options.setOption(MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_ALWAYS, CleanUpOptions.FALSE); options.setOption(MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_IF_NECESSARY, CleanUpOptions.TRUE); options.setOption(MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS, CleanUpOptions.FALSE); options.setOption(MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS_ALWAYS, CleanUpOptions.FALSE); options.setOption(MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS_IF_NECESSARY, CleanUpOptions.TRUE); options.setOption(MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS, CleanUpOptions.TRUE); options.setOption(MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_FIELD, CleanUpOptions.FALSE); options.setOption(MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_METHOD, CleanUpOptions.FALSE); options.setOption(MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_SUBTYPE_ACCESS, CleanUpOptions.TRUE); options.setOption(MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_INSTANCE_ACCESS, CleanUpOptions.TRUE); options.setOption(CONTROL_STATEMENTS_USE_BLOCKS, CleanUpOptions.FALSE); options.setOption(CONTROL_STATMENTS_USE_BLOCKS_ALWAYS, CleanUpOptions.TRUE); options.setOption(CONTROL_STATMENTS_USE_BLOCKS_NO_FOR_RETURN_AND_THROW, CleanUpOptions.FALSE); options.setOption(CONTROL_STATMENTS_USE_BLOCKS_NEVER, CleanUpOptions.FALSE); options.setOption(CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED, CleanUpOptions.FALSE); options.setOption(EXPRESSIONS_USE_PARENTHESES, CleanUpOptions.FALSE); options.setOption(EXPRESSIONS_USE_PARENTHESES_NEVER, CleanUpOptions.TRUE); options.setOption(EXPRESSIONS_USE_PARENTHESES_ALWAYS, CleanUpOptions.FALSE); options.setOption(VARIABLE_DECLARATIONS_USE_FINAL, CleanUpOptions.FALSE); options.setOption(VARIABLE_DECLARATIONS_USE_FINAL_LOCAL_VARIABLES, CleanUpOptions.TRUE); options.setOption(VARIABLE_DECLARATIONS_USE_FINAL_PARAMETERS, CleanUpOptions.FALSE); options.setOption(VARIABLE_DECLARATIONS_USE_FINAL_PRIVATE_FIELDS, CleanUpOptions.TRUE);
/** * Returns the default options for the specified clean up kind. * * @param kind the kind of clean up for which to retrieve the options * @return the default options * * @see CleanUpConstants#DEFAULT_CLEAN_UP_OPTIONS * @see CleanUpConstants#DEFAULT_SAVE_ACTION_OPTIONS */ public MapCleanUpOptions getDefaultOptions(int kind) { ensureCleanUpInitializersRegistered(); CleanUpOptions options= new CleanUpOptions(); for (int i= 0; i < fCleanUpInitializerDescriptors.length; i++) { CleanUpInitializerDescriptor descriptor= fCleanUpInitializerDescriptors[i]; if (descriptor.getKind() == kind) { descriptor.getOptionsInitializer().setDefaultOptions(options); } } MapCleanUpOptions mapCleanUpOptions= new MapCleanUpOptions(); mapCleanUpOptions.addAll(options); return mapCleanUpOptions; }
private static Map<String, String> loadFromProject(IScopeContext context) { final Map<String, String> profileOptions= new HashMap<>(); IEclipsePreferences uiPrefs= context.getNode(JavaUI.ID_PLUGIN); CleanUpProfileVersioner versioner= new CleanUpProfileVersioner(); CleanUpOptions defaultOptions= JavaPlugin.getDefault().getCleanUpRegistry().getDefaultOptions(CleanUpConstants.DEFAULT_CLEAN_UP_OPTIONS); KeySet[] keySets= CleanUpProfileManager.KEY_SETS; boolean hasValues= false; for (int i= 0; i < keySets.length; i++) { KeySet keySet= keySets[i]; IEclipsePreferences preferences= context.getNode(keySet.getNodeName()); for (final Iterator<String> keyIter = keySet.getKeys().iterator(); keyIter.hasNext(); ) { final String key= keyIter.next(); String val= preferences.get(key, null); if (val != null) { hasValues= true; } else { val= defaultOptions.getValue(key); } profileOptions.put(key, val); } } if (!hasValues) return null; int version= uiPrefs.getInt(CleanUpConstants.CLEANUP_SETTINGS_VERSION_KEY, versioner.getFirstVersion()); if (version == versioner.getCurrentVersion()) return profileOptions; CustomProfile profile= new CustomProfile("tmp", profileOptions, version, versioner.getProfileKind()); //$NON-NLS-1$ versioner.update(profile); return profile.getSettings(); }
public static void initDefaults(IPreferenceStore store) { CleanUpOptions settings= JavaPlugin.getDefault().getCleanUpRegistry().getDefaultOptions(CleanUpConstants.DEFAULT_CLEAN_UP_OPTIONS); for (Iterator<String> iterator= settings.getKeys().iterator(); iterator.hasNext();) { String key= iterator.next(); store.setDefault(key, settings.getValue(key)); } store.setDefault(SHOW_CLEAN_UP_WIZARD, true); store.setDefault(CLEANUP_PROFILE, DEFAULT_PROFILE); store.setDefault(CLEANUP_ON_SAVE_PROFILE, DEFAULT_SAVE_PARTICIPANT_PROFILE); }
options.setOption(MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS, CleanUpOptions.FALSE); options.setOption(MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_ALWAYS, CleanUpOptions.FALSE); options.setOption(MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_IF_NECESSARY, CleanUpOptions.TRUE); options.setOption(MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS, CleanUpOptions.FALSE); options.setOption(MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS_ALWAYS, CleanUpOptions.FALSE); options.setOption(MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS_IF_NECESSARY, CleanUpOptions.TRUE); options.setOption(MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS, CleanUpOptions.FALSE); options.setOption(MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_FIELD, CleanUpOptions.FALSE); options.setOption(MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_METHOD, CleanUpOptions.FALSE); options.setOption(MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_SUBTYPE_ACCESS, CleanUpOptions.TRUE); options.setOption(MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_INSTANCE_ACCESS, CleanUpOptions.TRUE); options.setOption(CONTROL_STATEMENTS_USE_BLOCKS, CleanUpOptions.FALSE); options.setOption(CONTROL_STATMENTS_USE_BLOCKS_ALWAYS, CleanUpOptions.TRUE); options.setOption(CONTROL_STATMENTS_USE_BLOCKS_NO_FOR_RETURN_AND_THROW, CleanUpOptions.FALSE); options.setOption(CONTROL_STATMENTS_USE_BLOCKS_NEVER, CleanUpOptions.FALSE); options.setOption(CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED, CleanUpOptions.FALSE); options.setOption(EXPRESSIONS_USE_PARENTHESES, CleanUpOptions.FALSE); options.setOption(EXPRESSIONS_USE_PARENTHESES_NEVER, CleanUpOptions.TRUE); options.setOption(EXPRESSIONS_USE_PARENTHESES_ALWAYS, CleanUpOptions.FALSE); options.setOption(VARIABLE_DECLARATIONS_USE_FINAL, CleanUpOptions.FALSE); options.setOption(VARIABLE_DECLARATIONS_USE_FINAL_LOCAL_VARIABLES, CleanUpOptions.TRUE); options.setOption(VARIABLE_DECLARATIONS_USE_FINAL_PARAMETERS, CleanUpOptions.FALSE); options.setOption(VARIABLE_DECLARATIONS_USE_FINAL_PRIVATE_FIELDS, CleanUpOptions.TRUE);
@Override public void run() throws Exception { ICleanUp cleanUp= cleanUpDescriptor.createCleanUp(); if (cleanUp == null) disable[0]= true; else { cleanUp.setOptions(new CleanUpOptions()); String[] enbledSteps= cleanUp.getStepDescriptions(); if (enbledSteps != null && enbledSteps.length > 0) { JavaPlugin.logErrorMessage( Messages.format(FixMessages.CleanUpRegistry_cleanUpAlwaysEnabled_error, new String[] { cleanUpDescriptor.getId(), cleanUpDescriptor.fElement.getContributor().getName() })); disable[0]= true; } } } @Override
@Override public void setOption(String key, String value) { super.setOption(key, value); doUpdatePreview(); notifyValuesModified(); } };