|
Lines 58-76
Link Here
|
| 58 |
package org.eclipse.jdt.core; |
58 |
package org.eclipse.jdt.core; |
| 59 |
|
59 |
|
| 60 |
import java.io.File; |
60 |
import java.io.File; |
| 61 |
import java.util.*; |
61 |
import java.util.Enumeration; |
| 62 |
|
62 |
import java.util.HashMap; |
| 63 |
import org.eclipse.core.resources.*; |
63 |
import java.util.HashSet; |
| 64 |
import org.eclipse.core.runtime.*; |
64 |
import java.util.Hashtable; |
|
|
65 |
import java.util.Iterator; |
| 66 |
import java.util.Map; |
| 67 |
|
| 68 |
import org.eclipse.core.resources.IContainer; |
| 69 |
import org.eclipse.core.resources.IFile; |
| 70 |
import org.eclipse.core.resources.IFolder; |
| 71 |
import org.eclipse.core.resources.IMarker; |
| 72 |
import org.eclipse.core.resources.IMarkerDelta; |
| 73 |
import org.eclipse.core.resources.IProject; |
| 74 |
import org.eclipse.core.resources.IResource; |
| 75 |
import org.eclipse.core.resources.IResourceChangeEvent; |
| 76 |
import org.eclipse.core.resources.IResourceChangeListener; |
| 77 |
import org.eclipse.core.resources.ISavedState; |
| 78 |
import org.eclipse.core.resources.IWorkspace; |
| 79 |
import org.eclipse.core.resources.IWorkspaceRoot; |
| 80 |
import org.eclipse.core.resources.IWorkspaceRunnable; |
| 81 |
import org.eclipse.core.resources.ResourcesPlugin; |
| 82 |
import org.eclipse.core.runtime.CoreException; |
| 83 |
import org.eclipse.core.runtime.IConfigurationElement; |
| 84 |
import org.eclipse.core.runtime.IExtension; |
| 85 |
import org.eclipse.core.runtime.IExtensionPoint; |
| 86 |
import org.eclipse.core.runtime.IPath; |
| 87 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 88 |
import org.eclipse.core.runtime.Platform; |
| 89 |
import org.eclipse.core.runtime.Plugin; |
| 65 |
import org.eclipse.core.runtime.jobs.ISchedulingRule; |
90 |
import org.eclipse.core.runtime.jobs.ISchedulingRule; |
|
|
91 |
import org.eclipse.core.runtime.preferences.DefaultScope; |
| 92 |
import org.eclipse.core.runtime.preferences.IEclipsePreferences; |
| 93 |
import org.eclipse.core.runtime.preferences.IPreferencesService; |
| 94 |
import org.eclipse.core.runtime.preferences.InstanceScope; |
| 66 |
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; |
95 |
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; |
| 67 |
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; |
96 |
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; |
| 68 |
import org.eclipse.jdt.internal.compiler.util.SuffixConstants; |
97 |
import org.eclipse.jdt.internal.compiler.util.SuffixConstants; |
| 69 |
import org.eclipse.jdt.internal.core.*; |
98 |
import org.eclipse.jdt.internal.core.Assert; |
|
|
99 |
import org.eclipse.jdt.internal.core.BatchOperation; |
| 100 |
import org.eclipse.jdt.internal.core.BufferFactoryWrapper; |
| 101 |
import org.eclipse.jdt.internal.core.BufferManager; |
| 102 |
import org.eclipse.jdt.internal.core.ClasspathEntry; |
| 103 |
import org.eclipse.jdt.internal.core.DefaultWorkingCopyOwner; |
| 104 |
import org.eclipse.jdt.internal.core.JavaModel; |
| 105 |
import org.eclipse.jdt.internal.core.JavaModelManager; |
| 106 |
import org.eclipse.jdt.internal.core.JavaProject; |
| 107 |
import org.eclipse.jdt.internal.core.Region; |
| 108 |
import org.eclipse.jdt.internal.core.SetClasspathOperation; |
| 109 |
import org.eclipse.jdt.internal.core.UserLibraryManager; |
| 70 |
import org.eclipse.jdt.internal.core.search.processing.IJob; |
110 |
import org.eclipse.jdt.internal.core.search.processing.IJob; |
| 71 |
import org.eclipse.jdt.internal.core.util.MementoTokenizer; |
111 |
import org.eclipse.jdt.internal.core.util.MementoTokenizer; |
| 72 |
import org.eclipse.jdt.internal.core.util.Util; |
112 |
import org.eclipse.jdt.internal.core.util.Util; |
| 73 |
import org.osgi.framework.BundleContext; |
113 |
import org.osgi.framework.BundleContext; |
|
|
114 |
import org.osgi.service.prefs.BackingStoreException; |
| 74 |
|
115 |
|
| 75 |
/** |
116 |
/** |
| 76 |
* The plug-in runtime class for the Java model plug-in containing the core |
117 |
* The plug-in runtime class for the Java model plug-in containing the core |
|
Lines 880-885
Link Here
|
| 880 |
public static final String PRIVATE = "private"; //$NON-NLS-1$ |
921 |
public static final String PRIVATE = "private"; //$NON-NLS-1$ |
| 881 |
|
922 |
|
| 882 |
/** |
923 |
/** |
|
|
924 |
* New Preferences API |
| 925 |
* @since 3.1 |
| 926 |
*/ |
| 927 |
public static final IEclipsePreferences[] preferencesLookup = new IEclipsePreferences[2]; |
| 928 |
static final int PREF_INSTANCE = 0; |
| 929 |
static final int PREF_DEFAULT = 1; |
| 930 |
|
| 931 |
/** |
| 883 |
* Creates the Java core plug-in. |
932 |
* Creates the Java core plug-in. |
| 884 |
* <p> |
933 |
* <p> |
| 885 |
* The plug-in instance is created automatically by the |
934 |
* The plug-in instance is created automatically by the |
|
Lines 969-975
Link Here
|
| 969 |
* </p> |
1018 |
* </p> |
| 970 |
* |
1019 |
* |
| 971 |
* @param listener the listener |
1020 |
* @param listener the listener |
| 972 |
* @see #removePreResourceChangeListener(IResourceChangeListener) |
1021 |
* @see #removePreProcessingResourceChangedListener(IResourceChangeListener) |
| 973 |
* @since 3.0 |
1022 |
* @since 3.0 |
| 974 |
*/ |
1023 |
*/ |
| 975 |
public static void addPreProcessingResourceChangedListener(IResourceChangeListener listener) { |
1024 |
public static void addPreProcessingResourceChangedListener(IResourceChangeListener listener) { |
|
Lines 2126-2139
Link Here
|
| 2126 |
Hashtable defaultOptions = new Hashtable(10); |
2175 |
Hashtable defaultOptions = new Hashtable(10); |
| 2127 |
|
2176 |
|
| 2128 |
// see #initializeDefaultPluginPreferences() for changing default settings |
2177 |
// see #initializeDefaultPluginPreferences() for changing default settings |
| 2129 |
Preferences preferences = getPlugin().getPluginPreferences(); |
2178 |
IEclipsePreferences defaultPreferences = getDefaultPreferences(); |
| 2130 |
HashSet optionNames = JavaModelManager.getJavaModelManager().optionNames; |
2179 |
HashSet optionNames = JavaModelManager.getJavaModelManager().optionNames; |
| 2131 |
|
2180 |
|
| 2132 |
// initialize preferences to their default |
2181 |
// initialize preferences to their default |
| 2133 |
Iterator iterator = optionNames.iterator(); |
2182 |
Iterator iterator = optionNames.iterator(); |
| 2134 |
while (iterator.hasNext()) { |
2183 |
while (iterator.hasNext()) { |
| 2135 |
String propertyName = (String) iterator.next(); |
2184 |
String propertyName = (String) iterator.next(); |
| 2136 |
defaultOptions.put(propertyName, preferences.getDefaultString(propertyName)); |
2185 |
String value = defaultPreferences.get(propertyName, null); |
|
|
2186 |
if (value != null) defaultOptions.put(propertyName, value); |
| 2137 |
} |
2187 |
} |
| 2138 |
// get encoding through resource plugin |
2188 |
// get encoding through resource plugin |
| 2139 |
defaultOptions.put(CORE_ENCODING, getEncoding()); |
2189 |
defaultOptions.put(CORE_ENCODING, getEncoding()); |
|
Lines 2143-2148
Link Here
|
| 2143 |
|
2193 |
|
| 2144 |
return defaultOptions; |
2194 |
return defaultOptions; |
| 2145 |
} |
2195 |
} |
|
|
2196 |
|
| 2197 |
/** |
| 2198 |
* @since 3.1 |
| 2199 |
*/ |
| 2200 |
public static IEclipsePreferences getInstancePreferences() { |
| 2201 |
if (preferencesLookup[PREF_INSTANCE] == null) { |
| 2202 |
preferencesLookup[PREF_INSTANCE] = new InstanceScope().getNode(PLUGIN_ID); |
| 2203 |
} |
| 2204 |
return preferencesLookup[PREF_INSTANCE]; |
| 2205 |
} |
| 2206 |
|
| 2207 |
/** |
| 2208 |
* @since 3.1 |
| 2209 |
*/ |
| 2210 |
public static IEclipsePreferences getDefaultPreferences() { |
| 2211 |
if (preferencesLookup[PREF_DEFAULT] == null) { |
| 2212 |
preferencesLookup[PREF_DEFAULT] = new DefaultScope().getNode(PLUGIN_ID); |
| 2213 |
} |
| 2214 |
return preferencesLookup[PREF_DEFAULT]; |
| 2215 |
} |
| 2146 |
|
2216 |
|
| 2147 |
/** |
2217 |
/** |
| 2148 |
* Returns the workspace root default charset encoding. |
2218 |
* Returns the workspace root default charset encoding. |
|
Lines 2153-2164
Link Here
|
| 2153 |
* @since 3.0 |
2223 |
* @since 3.0 |
| 2154 |
*/ |
2224 |
*/ |
| 2155 |
public static String getEncoding() { |
2225 |
public static String getEncoding() { |
| 2156 |
try { |
2226 |
// Verify that workspace is not shutting down (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=60687) |
| 2157 |
return ResourcesPlugin.getWorkspace().getRoot().getDefaultCharset(); |
2227 |
IWorkspace workspace = ResourcesPlugin.getWorkspace(); |
| 2158 |
} catch (Exception e) { |
2228 |
if (workspace != null) { |
| 2159 |
// fails silently and return plugin global encoding if core exception occurs or |
2229 |
try { |
| 2160 |
// if workspace is shutting down (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=60687) |
2230 |
return workspace.getRoot().getDefaultCharset(); |
| 2161 |
} |
2231 |
} catch (CoreException e) { |
|
|
2232 |
// fails silently and return plugin global encoding if core exception occurs |
| 2233 |
} |
| 2234 |
} |
| 2162 |
return ResourcesPlugin.getEncoding(); |
2235 |
return ResourcesPlugin.getEncoding(); |
| 2163 |
} |
2236 |
} |
| 2164 |
|
2237 |
|
|
Lines 2182-2187
Link Here
|
| 2182 |
* @param optionName the name of an option |
2255 |
* @param optionName the name of an option |
| 2183 |
* @return the String value of a given option |
2256 |
* @return the String value of a given option |
| 2184 |
* @see JavaCore#getDefaultOptions() |
2257 |
* @see JavaCore#getDefaultOptions() |
|
|
2258 |
* @see #initializeDefaultPreferences() for changing default settings |
| 2185 |
* @since 2.0 |
2259 |
* @since 2.0 |
| 2186 |
*/ |
2260 |
*/ |
| 2187 |
public static String getOption(String optionName) { |
2261 |
public static String getOption(String optionName) { |
|
Lines 2196-2203
Link Here
|
| 2196 |
} |
2270 |
} |
| 2197 |
String propertyName = optionName; |
2271 |
String propertyName = optionName; |
| 2198 |
if (JavaModelManager.getJavaModelManager().optionNames.contains(propertyName)){ |
2272 |
if (JavaModelManager.getJavaModelManager().optionNames.contains(propertyName)){ |
| 2199 |
Preferences preferences = getPlugin().getPluginPreferences(); |
2273 |
IPreferencesService service = Platform.getPreferencesService(); |
| 2200 |
return preferences.getString(propertyName).trim(); |
2274 |
String value = service.get(optionName, null, preferencesLookup); |
|
|
2275 |
return value==null ? null : value.trim(); |
| 2201 |
} |
2276 |
} |
| 2202 |
return null; |
2277 |
return null; |
| 2203 |
} |
2278 |
} |
|
Lines 2211-2249
Link Here
|
| 2211 |
* |
2286 |
* |
| 2212 |
* @return table of current settings of all options |
2287 |
* @return table of current settings of all options |
| 2213 |
* (key type: <code>String</code>; value type: <code>String</code>) |
2288 |
* (key type: <code>String</code>; value type: <code>String</code>) |
| 2214 |
* @see JavaCore#getDefaultOptions() |
2289 |
* @see #getDefaultOptions() |
|
|
2290 |
* @see #initializeDefaultPreferences() for changing default settings |
| 2215 |
*/ |
2291 |
*/ |
| 2216 |
public static Hashtable getOptions() { |
2292 |
public static Hashtable getOptions() { |
| 2217 |
|
2293 |
|
|
|
2294 |
// init |
| 2218 |
Hashtable options = new Hashtable(10); |
2295 |
Hashtable options = new Hashtable(10); |
|
|
2296 |
HashSet optionNames = JavaModelManager.getJavaModelManager().optionNames; |
| 2297 |
IPreferencesService service = Platform.getPreferencesService(); |
| 2219 |
|
2298 |
|
| 2220 |
// see #initializeDefaultPluginPreferences() for changing default settings |
2299 |
// set options using preferences service lookup |
| 2221 |
Plugin plugin = getPlugin(); |
2300 |
Iterator iterator = optionNames.iterator(); |
| 2222 |
if (plugin != null) { |
2301 |
while (iterator.hasNext()) { |
| 2223 |
Preferences preferences = getPlugin().getPluginPreferences(); |
2302 |
String propertyName = (String) iterator.next(); |
| 2224 |
HashSet optionNames = JavaModelManager.getJavaModelManager().optionNames; |
2303 |
String propertyValue = service.get(propertyName, null, preferencesLookup); |
| 2225 |
|
2304 |
if (propertyValue != null) { |
| 2226 |
// initialize preferences to their default |
2305 |
options.put(propertyName, propertyValue); |
| 2227 |
Iterator iterator = optionNames.iterator(); |
2306 |
} |
| 2228 |
while (iterator.hasNext()) { |
|
|
| 2229 |
String propertyName = (String) iterator.next(); |
| 2230 |
options.put(propertyName, preferences.getDefaultString(propertyName)); |
| 2231 |
} |
| 2232 |
// get preferences not set to their default |
| 2233 |
String[] propertyNames = preferences.propertyNames(); |
| 2234 |
for (int i = 0; i < propertyNames.length; i++){ |
| 2235 |
String propertyName = propertyNames[i]; |
| 2236 |
String value = preferences.getString(propertyName).trim(); |
| 2237 |
if (optionNames.contains(propertyName)){ |
| 2238 |
options.put(propertyName, value); |
| 2239 |
} |
| 2240 |
} |
| 2241 |
// get encoding through resource plugin |
| 2242 |
options.put(CORE_ENCODING, getEncoding()); |
| 2243 |
// backward compatibility |
| 2244 |
options.put(COMPILER_PB_INVALID_IMPORT, ERROR); |
| 2245 |
options.put(COMPILER_PB_UNREACHABLE_CODE, ERROR); |
| 2246 |
} |
2307 |
} |
|
|
2308 |
|
| 2309 |
// get encoding through resource plugin |
| 2310 |
options.put(CORE_ENCODING, getEncoding()); |
| 2311 |
|
| 2312 |
// backward compatibility |
| 2313 |
options.put(COMPILER_PB_INVALID_IMPORT, ERROR); |
| 2314 |
options.put(COMPILER_PB_UNREACHABLE_CODE, ERROR); |
| 2315 |
|
| 2316 |
// return built map |
| 2247 |
return options; |
2317 |
return options; |
| 2248 |
} |
2318 |
} |
| 2249 |
|
2319 |
|
|
Lines 2423-2435
Link Here
|
| 2423 |
if (result == null) return JavaModelManager.NO_WORKING_COPY; |
2493 |
if (result == null) return JavaModelManager.NO_WORKING_COPY; |
| 2424 |
return result; |
2494 |
return result; |
| 2425 |
} |
2495 |
} |
| 2426 |
|
2496 |
|
| 2427 |
/** |
2497 |
/* |
| 2428 |
* Initializes the default preferences settings for this plug-in. |
2498 |
* Initializes the default preferences settings for this plug-in. |
| 2429 |
*/ |
2499 |
*/ |
| 2430 |
protected void initializeDefaultPluginPreferences() { |
2500 |
protected void initializeDefaultPreferences() { |
|
|
2501 |
|
| 2502 |
// Init and store default and instance preferences |
| 2503 |
IEclipsePreferences defaultPreferences = getDefaultPreferences(); |
| 2431 |
|
2504 |
|
| 2432 |
Preferences preferences = getPluginPreferences(); |
|
|
| 2433 |
HashSet optionNames = JavaModelManager.getJavaModelManager().optionNames; |
2505 |
HashSet optionNames = JavaModelManager.getJavaModelManager().optionNames; |
| 2434 |
|
2506 |
|
| 2435 |
// Compiler settings |
2507 |
// Compiler settings |
|
Lines 2437-2483
Link Here
|
| 2437 |
for (Iterator iter = compilerOptionsMap.entrySet().iterator(); iter.hasNext();) { |
2509 |
for (Iterator iter = compilerOptionsMap.entrySet().iterator(); iter.hasNext();) { |
| 2438 |
Map.Entry entry = (Map.Entry) iter.next(); |
2510 |
Map.Entry entry = (Map.Entry) iter.next(); |
| 2439 |
String optionName = (String) entry.getKey(); |
2511 |
String optionName = (String) entry.getKey(); |
| 2440 |
preferences.setDefault(optionName, (String)entry.getValue()); |
2512 |
defaultPreferences.put(optionName, (String)entry.getValue()); |
| 2441 |
optionNames.add(optionName); |
2513 |
optionNames.add(optionName); |
| 2442 |
} |
2514 |
} |
| 2443 |
// override some compiler defaults |
2515 |
// override some compiler defaults |
| 2444 |
preferences.setDefault(COMPILER_LOCAL_VARIABLE_ATTR, GENERATE); |
2516 |
defaultPreferences.put(COMPILER_LOCAL_VARIABLE_ATTR, GENERATE); |
| 2445 |
preferences.setDefault(COMPILER_CODEGEN_UNUSED_LOCAL, PRESERVE); |
2517 |
defaultPreferences.put(COMPILER_CODEGEN_UNUSED_LOCAL, PRESERVE); |
| 2446 |
preferences.setDefault(COMPILER_TASK_TAGS, DEFAULT_TASK_TAGS); |
2518 |
defaultPreferences.put(COMPILER_TASK_TAGS, DEFAULT_TASK_TAGS); |
| 2447 |
preferences.setDefault(COMPILER_TASK_PRIORITIES, DEFAULT_TASK_PRIORITIES); |
2519 |
defaultPreferences.put(COMPILER_TASK_PRIORITIES, DEFAULT_TASK_PRIORITIES); |
| 2448 |
preferences.setDefault(COMPILER_TASK_CASE_SENSITIVE, ENABLED); |
2520 |
defaultPreferences.put(COMPILER_TASK_CASE_SENSITIVE, ENABLED); |
| 2449 |
preferences.setDefault(COMPILER_DOC_COMMENT_SUPPORT, ENABLED); |
2521 |
defaultPreferences.put(COMPILER_DOC_COMMENT_SUPPORT, ENABLED); |
| 2450 |
|
2522 |
|
| 2451 |
// Builder settings |
2523 |
// Builder settings |
| 2452 |
preferences.setDefault(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, ""); //$NON-NLS-1$ |
2524 |
defaultPreferences.put(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, ""); //$NON-NLS-1$ |
| 2453 |
optionNames.add(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER); |
2525 |
optionNames.add(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER); |
| 2454 |
|
2526 |
|
| 2455 |
preferences.setDefault(CORE_JAVA_BUILD_INVALID_CLASSPATH, ABORT); |
2527 |
defaultPreferences.put(CORE_JAVA_BUILD_INVALID_CLASSPATH, ABORT); |
| 2456 |
optionNames.add(CORE_JAVA_BUILD_INVALID_CLASSPATH); |
2528 |
optionNames.add(CORE_JAVA_BUILD_INVALID_CLASSPATH); |
| 2457 |
|
2529 |
|
| 2458 |
preferences.setDefault(CORE_JAVA_BUILD_DUPLICATE_RESOURCE, WARNING); |
2530 |
defaultPreferences.put(CORE_JAVA_BUILD_DUPLICATE_RESOURCE, WARNING); |
| 2459 |
optionNames.add(CORE_JAVA_BUILD_DUPLICATE_RESOURCE); |
2531 |
optionNames.add(CORE_JAVA_BUILD_DUPLICATE_RESOURCE); |
| 2460 |
|
2532 |
|
| 2461 |
preferences.setDefault(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, CLEAN); |
2533 |
defaultPreferences.put(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, CLEAN); |
| 2462 |
optionNames.add(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER); |
2534 |
optionNames.add(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER); |
| 2463 |
|
2535 |
|
| 2464 |
// JavaCore settings |
2536 |
// JavaCore settings |
| 2465 |
preferences.setDefault(CORE_JAVA_BUILD_ORDER, IGNORE); |
2537 |
defaultPreferences.put(CORE_JAVA_BUILD_ORDER, IGNORE); |
| 2466 |
optionNames.add(CORE_JAVA_BUILD_ORDER); |
2538 |
optionNames.add(CORE_JAVA_BUILD_ORDER); |
| 2467 |
|
2539 |
|
| 2468 |
preferences.setDefault(CORE_INCOMPLETE_CLASSPATH, ERROR); |
2540 |
defaultPreferences.put(CORE_INCOMPLETE_CLASSPATH, ERROR); |
| 2469 |
optionNames.add(CORE_INCOMPLETE_CLASSPATH); |
2541 |
optionNames.add(CORE_INCOMPLETE_CLASSPATH); |
| 2470 |
|
2542 |
|
| 2471 |
preferences.setDefault(CORE_CIRCULAR_CLASSPATH, ERROR); |
2543 |
defaultPreferences.put(CORE_CIRCULAR_CLASSPATH, ERROR); |
| 2472 |
optionNames.add(CORE_CIRCULAR_CLASSPATH); |
2544 |
optionNames.add(CORE_CIRCULAR_CLASSPATH); |
| 2473 |
|
2545 |
|
| 2474 |
preferences.setDefault(CORE_INCOMPATIBLE_JDK_LEVEL, IGNORE); |
2546 |
defaultPreferences.put(CORE_INCOMPATIBLE_JDK_LEVEL, IGNORE); |
| 2475 |
optionNames.add(CORE_INCOMPATIBLE_JDK_LEVEL); |
2547 |
optionNames.add(CORE_INCOMPATIBLE_JDK_LEVEL); |
| 2476 |
|
2548 |
|
| 2477 |
preferences.setDefault(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS, ENABLED); |
2549 |
defaultPreferences.put(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS, ENABLED); |
| 2478 |
optionNames.add(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS); |
2550 |
optionNames.add(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS); |
| 2479 |
|
2551 |
|
| 2480 |
preferences.setDefault(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS, ENABLED); |
2552 |
defaultPreferences.put(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS, ENABLED); |
| 2481 |
optionNames.add(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS); |
2553 |
optionNames.add(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS); |
| 2482 |
|
2554 |
|
| 2483 |
// encoding setting comes from resource plug-in |
2555 |
// encoding setting comes from resource plug-in |
|
Lines 2488-2555
Link Here
|
| 2488 |
for (Iterator iter = codeFormatterOptionsMap.entrySet().iterator(); iter.hasNext();) { |
2560 |
for (Iterator iter = codeFormatterOptionsMap.entrySet().iterator(); iter.hasNext();) { |
| 2489 |
Map.Entry entry = (Map.Entry) iter.next(); |
2561 |
Map.Entry entry = (Map.Entry) iter.next(); |
| 2490 |
String optionName = (String) entry.getKey(); |
2562 |
String optionName = (String) entry.getKey(); |
| 2491 |
preferences.setDefault(optionName, (String)entry.getValue()); |
2563 |
defaultPreferences.put(optionName, (String)entry.getValue()); |
| 2492 |
optionNames.add(optionName); |
2564 |
optionNames.add(optionName); |
| 2493 |
} |
2565 |
} |
| 2494 |
preferences.setDefault(FORMATTER_NEWLINE_OPENING_BRACE, DO_NOT_INSERT); |
2566 |
defaultPreferences.put(FORMATTER_NEWLINE_OPENING_BRACE, DO_NOT_INSERT); |
| 2495 |
optionNames.add(FORMATTER_NEWLINE_OPENING_BRACE); |
2567 |
optionNames.add(FORMATTER_NEWLINE_OPENING_BRACE); |
| 2496 |
|
2568 |
|
| 2497 |
preferences.setDefault(FORMATTER_NEWLINE_CONTROL, DO_NOT_INSERT); |
2569 |
defaultPreferences.put(FORMATTER_NEWLINE_CONTROL, DO_NOT_INSERT); |
| 2498 |
optionNames.add(FORMATTER_NEWLINE_CONTROL); |
2570 |
optionNames.add(FORMATTER_NEWLINE_CONTROL); |
| 2499 |
|
2571 |
|
| 2500 |
preferences.setDefault(FORMATTER_CLEAR_BLANK_LINES, PRESERVE_ONE); |
2572 |
defaultPreferences.put(FORMATTER_CLEAR_BLANK_LINES, PRESERVE_ONE); |
| 2501 |
optionNames.add(FORMATTER_CLEAR_BLANK_LINES); |
2573 |
optionNames.add(FORMATTER_CLEAR_BLANK_LINES); |
| 2502 |
|
2574 |
|
| 2503 |
preferences.setDefault(FORMATTER_NEWLINE_ELSE_IF, DO_NOT_INSERT); |
2575 |
defaultPreferences.put(FORMATTER_NEWLINE_ELSE_IF, DO_NOT_INSERT); |
| 2504 |
optionNames.add(FORMATTER_NEWLINE_ELSE_IF); |
2576 |
optionNames.add(FORMATTER_NEWLINE_ELSE_IF); |
| 2505 |
|
2577 |
|
| 2506 |
preferences.setDefault(FORMATTER_NEWLINE_EMPTY_BLOCK, INSERT); |
2578 |
defaultPreferences.put(FORMATTER_NEWLINE_EMPTY_BLOCK, INSERT); |
| 2507 |
optionNames.add(FORMATTER_NEWLINE_EMPTY_BLOCK); |
2579 |
optionNames.add(FORMATTER_NEWLINE_EMPTY_BLOCK); |
| 2508 |
|
2580 |
|
| 2509 |
preferences.setDefault(FORMATTER_LINE_SPLIT, "80"); //$NON-NLS-1$ |
2581 |
defaultPreferences.put(FORMATTER_LINE_SPLIT, "80"); //$NON-NLS-1$ |
| 2510 |
optionNames.add(FORMATTER_LINE_SPLIT); |
2582 |
optionNames.add(FORMATTER_LINE_SPLIT); |
| 2511 |
|
2583 |
|
| 2512 |
preferences.setDefault(FORMATTER_COMPACT_ASSIGNMENT, NORMAL); |
2584 |
defaultPreferences.put(FORMATTER_COMPACT_ASSIGNMENT, NORMAL); |
| 2513 |
optionNames.add(FORMATTER_COMPACT_ASSIGNMENT); |
2585 |
optionNames.add(FORMATTER_COMPACT_ASSIGNMENT); |
| 2514 |
|
2586 |
|
| 2515 |
preferences.setDefault(FORMATTER_TAB_CHAR, TAB); |
2587 |
defaultPreferences.put(FORMATTER_TAB_CHAR, TAB); |
| 2516 |
optionNames.add(FORMATTER_TAB_CHAR); |
2588 |
optionNames.add(FORMATTER_TAB_CHAR); |
| 2517 |
|
2589 |
|
| 2518 |
preferences.setDefault(FORMATTER_TAB_SIZE, "4"); //$NON-NLS-1$ |
2590 |
defaultPreferences.put(FORMATTER_TAB_SIZE, "4"); //$NON-NLS-1$ |
| 2519 |
optionNames.add(FORMATTER_TAB_SIZE); |
2591 |
optionNames.add(FORMATTER_TAB_SIZE); |
| 2520 |
|
2592 |
|
| 2521 |
preferences.setDefault(FORMATTER_SPACE_CASTEXPRESSION, INSERT); //$NON-NLS-1$ |
2593 |
defaultPreferences.put(FORMATTER_SPACE_CASTEXPRESSION, INSERT); //$NON-NLS-1$ |
| 2522 |
optionNames.add(FORMATTER_SPACE_CASTEXPRESSION); |
2594 |
optionNames.add(FORMATTER_SPACE_CASTEXPRESSION); |
| 2523 |
|
2595 |
|
| 2524 |
// CodeAssist settings |
2596 |
// CodeAssist settings |
| 2525 |
preferences.setDefault(CODEASSIST_VISIBILITY_CHECK, DISABLED); //$NON-NLS-1$ |
2597 |
defaultPreferences.put(CODEASSIST_VISIBILITY_CHECK, DISABLED); //$NON-NLS-1$ |
| 2526 |
optionNames.add(CODEASSIST_VISIBILITY_CHECK); |
2598 |
optionNames.add(CODEASSIST_VISIBILITY_CHECK); |
| 2527 |
|
2599 |
|
| 2528 |
preferences.setDefault(CODEASSIST_IMPLICIT_QUALIFICATION, DISABLED); //$NON-NLS-1$ |
2600 |
defaultPreferences.put(CODEASSIST_IMPLICIT_QUALIFICATION, DISABLED); //$NON-NLS-1$ |
| 2529 |
optionNames.add(CODEASSIST_IMPLICIT_QUALIFICATION); |
2601 |
optionNames.add(CODEASSIST_IMPLICIT_QUALIFICATION); |
| 2530 |
|
2602 |
|
| 2531 |
preferences.setDefault(CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$ |
2603 |
defaultPreferences.put(CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$ |
| 2532 |
optionNames.add(CODEASSIST_FIELD_PREFIXES); |
2604 |
optionNames.add(CODEASSIST_FIELD_PREFIXES); |
| 2533 |
|
2605 |
|
| 2534 |
preferences.setDefault(CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$ |
2606 |
defaultPreferences.put(CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$ |
| 2535 |
optionNames.add(CODEASSIST_STATIC_FIELD_PREFIXES); |
2607 |
optionNames.add(CODEASSIST_STATIC_FIELD_PREFIXES); |
| 2536 |
|
2608 |
|
| 2537 |
preferences.setDefault(CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$ |
2609 |
defaultPreferences.put(CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$ |
| 2538 |
optionNames.add(CODEASSIST_LOCAL_PREFIXES); |
2610 |
optionNames.add(CODEASSIST_LOCAL_PREFIXES); |
| 2539 |
|
2611 |
|
| 2540 |
preferences.setDefault(CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$ |
2612 |
defaultPreferences.put(CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$ |
| 2541 |
optionNames.add(CODEASSIST_ARGUMENT_PREFIXES); |
2613 |
optionNames.add(CODEASSIST_ARGUMENT_PREFIXES); |
| 2542 |
|
2614 |
|
| 2543 |
preferences.setDefault(CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$ |
2615 |
defaultPreferences.put(CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$ |
| 2544 |
optionNames.add(CODEASSIST_FIELD_SUFFIXES); |
2616 |
optionNames.add(CODEASSIST_FIELD_SUFFIXES); |
| 2545 |
|
2617 |
|
| 2546 |
preferences.setDefault(CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$ |
2618 |
defaultPreferences.put(CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$ |
| 2547 |
optionNames.add(CODEASSIST_STATIC_FIELD_SUFFIXES); |
2619 |
optionNames.add(CODEASSIST_STATIC_FIELD_SUFFIXES); |
| 2548 |
|
2620 |
|
| 2549 |
preferences.setDefault(CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$ |
2621 |
defaultPreferences.put(CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$ |
| 2550 |
optionNames.add(CODEASSIST_LOCAL_SUFFIXES); |
2622 |
optionNames.add(CODEASSIST_LOCAL_SUFFIXES); |
| 2551 |
|
2623 |
|
| 2552 |
preferences.setDefault(CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$ |
2624 |
defaultPreferences.put(CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$ |
| 2553 |
optionNames.add(CODEASSIST_ARGUMENT_SUFFIXES); |
2625 |
optionNames.add(CODEASSIST_ARGUMENT_SUFFIXES); |
| 2554 |
} |
2626 |
} |
| 2555 |
|
2627 |
|
|
Lines 3647-3672
Link Here
|
| 3647 |
* @param newOptions the new options (key type: <code>String</code>; value type: <code>String</code>), |
3719 |
* @param newOptions the new options (key type: <code>String</code>; value type: <code>String</code>), |
| 3648 |
* or <code>null</code> to reset all options to their default values |
3720 |
* or <code>null</code> to reset all options to their default values |
| 3649 |
* @see JavaCore#getDefaultOptions() |
3721 |
* @see JavaCore#getDefaultOptions() |
|
|
3722 |
* @see #initializeDefaultPreferences() for changing default settings |
| 3650 |
*/ |
3723 |
*/ |
| 3651 |
public static void setOptions(Hashtable newOptions) { |
3724 |
public static void setOptions(Hashtable newOptions) { |
| 3652 |
|
3725 |
|
| 3653 |
// see #initializeDefaultPluginPreferences() for changing default settings |
3726 |
try { |
| 3654 |
Preferences preferences = getPlugin().getPluginPreferences(); |
3727 |
IEclipsePreferences defaultPreferences = getDefaultPreferences(); |
|
|
3728 |
IEclipsePreferences instancePreferences = getInstancePreferences(); |
| 3655 |
|
3729 |
|
| 3656 |
if (newOptions == null){ |
3730 |
if (newOptions == null){ |
| 3657 |
newOptions = JavaCore.getDefaultOptions(); |
3731 |
instancePreferences.clear(); |
| 3658 |
} |
3732 |
} else { |
| 3659 |
Enumeration keys = newOptions.keys(); |
3733 |
Enumeration keys = newOptions.keys(); |
| 3660 |
while (keys.hasMoreElements()){ |
3734 |
while (keys.hasMoreElements()){ |
| 3661 |
String key = (String)keys.nextElement(); |
3735 |
String key = (String)keys.nextElement(); |
| 3662 |
if (!JavaModelManager.getJavaModelManager().optionNames.contains(key)) continue; // unrecognized option |
3736 |
if (!JavaModelManager.getJavaModelManager().optionNames.contains(key)) continue; // unrecognized option |
| 3663 |
if (key.equals(CORE_ENCODING)) continue; // skipped, contributed by resource prefs |
3737 |
if (key.equals(CORE_ENCODING)) continue; // skipped, contributed by resource prefs |
| 3664 |
String value = (String)newOptions.get(key); |
3738 |
String value = (String)newOptions.get(key); |
| 3665 |
preferences.setValue(key, value); |
3739 |
String defaultValue = defaultPreferences.get(key, null); |
| 3666 |
} |
3740 |
if (defaultValue != null && defaultValue.equals(value)) { |
|
|
3741 |
instancePreferences.remove(key); |
| 3742 |
} else { |
| 3743 |
instancePreferences.put(key, value); |
| 3744 |
} |
| 3745 |
} |
| 3746 |
} |
| 3667 |
|
3747 |
|
| 3668 |
// persist options |
3748 |
// persist options |
| 3669 |
getPlugin().savePluginPreferences(); |
3749 |
instancePreferences.flush(); |
|
|
3750 |
} catch (BackingStoreException e) { |
| 3751 |
// fails silently |
| 3752 |
} |
| 3670 |
} |
3753 |
} |
| 3671 |
|
3754 |
|
| 3672 |
/* (non-Javadoc) |
3755 |
/* (non-Javadoc) |
|
Lines 3711-3716
Link Here
|
| 3711 |
public void start(BundleContext context) throws Exception { |
3794 |
public void start(BundleContext context) throws Exception { |
| 3712 |
super.start(context); |
3795 |
super.start(context); |
| 3713 |
|
3796 |
|
|
|
3797 |
// init preferences |
| 3798 |
initializeDefaultPreferences(); |
| 3799 |
|
| 3714 |
final JavaModelManager manager = JavaModelManager.getJavaModelManager(); |
3800 |
final JavaModelManager manager = JavaModelManager.getJavaModelManager(); |
| 3715 |
try { |
3801 |
try { |
| 3716 |
manager.configurePluginDebugOptions(); |
3802 |
manager.configurePluginDebugOptions(); |
|
Lines 3719-3725
Link Here
|
| 3719 |
JavaCore.getPlugin().getStateLocation(); |
3805 |
JavaCore.getPlugin().getStateLocation(); |
| 3720 |
|
3806 |
|
| 3721 |
// retrieve variable values |
3807 |
// retrieve variable values |
| 3722 |
JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new JavaModelManager.PluginPreferencesListener()); |
3808 |
getInstancePreferences().addPreferenceChangeListener(new JavaModelManager.EclipsePreferencesListener()); |
| 3723 |
manager.loadVariablesAndContainers(); |
3809 |
manager.loadVariablesAndContainers(); |
| 3724 |
|
3810 |
|
| 3725 |
final IWorkspace workspace = ResourcesPlugin.getWorkspace(); |
3811 |
final IWorkspace workspace = ResourcesPlugin.getWorkspace(); |