List of usage examples for org.eclipse.jdt.internal.core.util Util fixTaskTags
public static void fixTaskTags(Map defaultOptionsMap)
From source file:org.eclipse.jdt.internal.core.JavaModelManager.java
License:Open Source License
public Hashtable getOptions() { // return cached options if already computed Hashtable cachedOptions; // use a local variable to avoid race condition (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=256329 ) if ((cachedOptions = this.optionsCache) != null) { return new Hashtable(cachedOptions); }/*from www . j a v a2s . c o m*/ if (!Platform.isRunning()) { this.optionsCache = getDefaultOptionsNoInitialization(); return new Hashtable(this.optionsCache); } // init Hashtable options = new Hashtable(10); IPreferencesService service = Platform.getPreferencesService(); // set options using preferences service lookup Iterator iterator = this.optionNames.iterator(); while (iterator.hasNext()) { String propertyName = (String) iterator.next(); String propertyValue = service.get(propertyName, null, this.preferencesLookup); if (propertyValue != null) { options.put(propertyName, propertyValue); } } // 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); Util.fixTaskTags(options); // store built map in cache this.optionsCache = new Hashtable(options); // return built map return options; }
From source file:org.eclipse.jdt.internal.core.JavaModelManager.java
License:Open Source License
public void setOptions(Hashtable newOptions) { Hashtable cachedValue = newOptions == null ? null : new Hashtable(newOptions); IEclipsePreferences defaultPreferences = getDefaultPreferences(); IEclipsePreferences instancePreferences = getInstancePreferences(); if (newOptions == null) { try {/* ww w.ja va2s. c o m*/ instancePreferences.clear(); } catch (BackingStoreException e) { // ignore } } else { Enumeration keys = newOptions.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); 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 defaultValue = defaultPreferences.get(key, null); // Store value in preferences if (defaultValue != null && defaultValue.equals(value)) { value = null; } storePreference(key, value, instancePreferences); } try { // persist options instancePreferences.flush(); } catch (BackingStoreException e) { // ignore } } // update cache Util.fixTaskTags(cachedValue); this.optionsCache = cachedValue; }
From source file:org.eclipse.jdt.internal.core.JavaProject.java
License:Open Source License
/** * @see org.eclipse.jdt.core.IJavaProject#getOptions(boolean) *///from w w w. j a v a 2 s . co m public Map getOptions(boolean inheritJavaCoreOptions) { // initialize to the defaults from JavaCore options pool Map options = inheritJavaCoreOptions ? JavaCore.getOptions() : new Hashtable(5); // Get project specific options JavaModelManager.PerProjectInfo perProjectInfo = null; Hashtable projectOptions = null; JavaModelManager javaModelManager = JavaModelManager.getJavaModelManager(); HashSet optionNames = javaModelManager.optionNames; try { perProjectInfo = getPerProjectInfo(); projectOptions = perProjectInfo.options; if (projectOptions == null) { // get eclipse preferences IEclipsePreferences projectPreferences = getEclipsePreferences(); if (projectPreferences == null) return options; // cannot do better (non-Java project) // create project options String[] propertyNames = projectPreferences.keys(); projectOptions = new Hashtable(propertyNames.length); for (int i = 0; i < propertyNames.length; i++) { String propertyName = propertyNames[i]; String value = projectPreferences.get(propertyName, null); if (value != null) { 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); } } } } } // cache project options perProjectInfo.options = projectOptions; } } catch (JavaModelException jme) { projectOptions = new Hashtable(); } catch (BackingStoreException e) { projectOptions = new Hashtable(); } // Inherit from JavaCore options if specified if (inheritJavaCoreOptions) { Iterator propertyNames = projectOptions.entrySet().iterator(); while (propertyNames.hasNext()) { Map.Entry entry = (Map.Entry) propertyNames.next(); String propertyName = (String) entry.getKey(); String propertyValue = (String) entry.getValue(); if (propertyValue != null && javaModelManager.knowsOption(propertyName)) { options.put(propertyName, propertyValue.trim()); } } Util.fixTaskTags(options); return options; } Util.fixTaskTags(projectOptions); return projectOptions; }