View | Details | Raw Unified | Return to bug 263564 | Differences between
and this patch

Collapse All | Expand All

(-)model/org/eclipse/jdt/core/JavaCore.java (-2 / +28 lines)
Lines 85-90 Link Here
85
package org.eclipse.jdt.core;
85
package org.eclipse.jdt.core;
86
86
87
import java.util.ArrayList;
87
import java.util.ArrayList;
88
import java.util.Collections;
88
import java.util.HashMap;
89
import java.util.HashMap;
89
import java.util.HashSet;
90
import java.util.HashSet;
90
import java.util.Hashtable;
91
import java.util.Hashtable;
Lines 2984-2991 Link Here
2984
	 *
2985
	 *
2985
	 * @return a table of all known configurable options with their default values
2986
	 * @return a table of all known configurable options with their default values
2986
	 */
2987
	 */
2987
 	public static Hashtable getDefaultOptions(){
2988
	public static Hashtable getDefaultOptions(){
2988
 		return JavaModelManager.getJavaModelManager().getDefaultOptions();
2989
		return JavaModelManager.getJavaModelManager().getDefaultOptions();
2990
	}
2991
	
2992
2993
	/**
2994
	 * Returns an immutable map of all known configurable options with their original default values
2995
	 * as defined by JDT/Core.
2996
	 * 
2997
	 * <p>The values of these options might be different from the values returned by {@link #getDefaultOptions()}
2998
	 * as {@link #getDefaultOptions()} returned the default options defined by an installation/product/configuration
2999
	 * (i.e. modified by the usage of a plugin_customization.ini file for example).
3000
	 * </p>
3001
	 * <p>These options allow to configure the behaviour of the underlying components.</p>
3002
	 * <p>If the map is being modified, an <tt>UnsupportedOperationException</tt> exception is thrown.</p>
3003
	 * <p>Helper constants have been defined on JavaCore for each of the option IDs
3004
	 * (categorized in Code assist option ID, Compiler option ID and Core option ID)
3005
	 * and some of their acceptable values (categorized in Option value). Some
3006
	 * options accept open value sets beyond the documented constant values.</p>
3007
	 * <p>Note: each release may add new options.</p>
3008
	 *
3009
	 * @return an immutable map of all known configurable options with their original default values
3010
	 * as defined by JDT/Core
3011
	 * @since 3.6
3012
	 */
3013
	public static Map getOriginalDefaultOptions(){
3014
		return Collections.unmodifiableMap(Util.getOriginalDefaultOptions(null));
2989
	}
3015
	}
2990
3016
2991
	/**
3017
	/**
(-)model/org/eclipse/jdt/internal/core/JavaCorePreferenceInitializer.java (-61 / +2 lines)
Lines 14-21 Link Here
14
14
15
import org.eclipse.core.runtime.preferences.*;
15
import org.eclipse.core.runtime.preferences.*;
16
import org.eclipse.jdt.core.JavaCore;
16
import org.eclipse.jdt.core.JavaCore;
17
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
17
import org.eclipse.jdt.internal.core.util.Util;
18
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
19
18
20
/**
19
/**
21
 * JavaCore eclipse preferences initializer.
20
 * JavaCore eclipse preferences initializer.
Lines 33-97 Link Here
33
		HashSet optionNames = JavaModelManager.getJavaModelManager().optionNames;
32
		HashSet optionNames = JavaModelManager.getJavaModelManager().optionNames;
34
33
35
		// Compiler settings
34
		// Compiler settings
36
		Map defaultOptionsMap = new CompilerOptions().getMap(); // compiler defaults
35
		Map defaultOptionsMap = Util.getOriginalDefaultOptions(optionNames);
37
38
		// Override some compiler defaults
39
		defaultOptionsMap.put(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR, JavaCore.GENERATE);
40
		defaultOptionsMap.put(JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL, JavaCore.PRESERVE);
41
		defaultOptionsMap.put(JavaCore.COMPILER_TASK_TAGS, JavaCore.DEFAULT_TASK_TAGS);
42
		defaultOptionsMap.put(JavaCore.COMPILER_TASK_PRIORITIES, JavaCore.DEFAULT_TASK_PRIORITIES);
43
		defaultOptionsMap.put(JavaCore.COMPILER_TASK_CASE_SENSITIVE, JavaCore.ENABLED);
44
		defaultOptionsMap.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED);
45
		defaultOptionsMap.put(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaCore.ERROR);
46
47
		// Builder settings
48
		defaultOptionsMap.put(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, ""); //$NON-NLS-1$
49
		defaultOptionsMap.put(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, JavaCore.ABORT);
50
		defaultOptionsMap.put(JavaCore.CORE_JAVA_BUILD_DUPLICATE_RESOURCE, JavaCore.WARNING);
51
		defaultOptionsMap.put(JavaCore.CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, JavaCore.CLEAN);
52
		defaultOptionsMap.put(JavaCore.CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER, JavaCore.IGNORE);
53
54
		// JavaCore settings
55
		defaultOptionsMap.put(JavaCore.CORE_JAVA_BUILD_ORDER, JavaCore.IGNORE);
56
		defaultOptionsMap.put(JavaCore.CORE_INCOMPLETE_CLASSPATH, JavaCore.ERROR);
57
		defaultOptionsMap.put(JavaCore.CORE_CIRCULAR_CLASSPATH, JavaCore.ERROR);
58
		defaultOptionsMap.put(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, JavaCore.IGNORE);
59
		defaultOptionsMap.put(JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS, JavaCore.ENABLED);
60
		defaultOptionsMap.put(JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS, JavaCore.ENABLED);
61
62
		// encoding setting comes from resource plug-in
63
		optionNames.add(JavaCore.CORE_ENCODING);
64
65
		// Formatter settings
66
		Map codeFormatterOptionsMap = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); // code formatter defaults
67
		for (Iterator iter = codeFormatterOptionsMap.entrySet().iterator(); iter.hasNext();) {
68
			Map.Entry entry = (Map.Entry) iter.next();
69
			String optionName = (String) entry.getKey();
70
			defaultOptionsMap.put(optionName, entry.getValue());
71
			optionNames.add(optionName);
72
		}
73
74
		// CodeAssist settings
75
		defaultOptionsMap.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.DISABLED);
76
		defaultOptionsMap.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.DISABLED);
77
		defaultOptionsMap.put(JavaCore.CODEASSIST_IMPLICIT_QUALIFICATION, JavaCore.DISABLED);
78
		defaultOptionsMap.put(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$
79
		defaultOptionsMap.put(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$
80
		defaultOptionsMap.put(JavaCore.CODEASSIST_STATIC_FINAL_FIELD_PREFIXES, ""); //$NON-NLS-1$
81
		defaultOptionsMap.put(JavaCore.CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$
82
		defaultOptionsMap.put(JavaCore.CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$
83
		defaultOptionsMap.put(JavaCore.CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$
84
		defaultOptionsMap.put(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$
85
		defaultOptionsMap.put(JavaCore.CODEASSIST_STATIC_FINAL_FIELD_SUFFIXES, ""); //$NON-NLS-1$
86
		defaultOptionsMap.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$
87
		defaultOptionsMap.put(JavaCore.CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$
88
		defaultOptionsMap.put(JavaCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaCore.ENABLED);
89
		defaultOptionsMap.put(JavaCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaCore.DISABLED);
90
		defaultOptionsMap.put(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
91
		defaultOptionsMap.put(JavaCore.CODEASSIST_SUGGEST_STATIC_IMPORTS, JavaCore.ENABLED);
92
93
		// Time out for parameter names
94
		defaultOptionsMap.put(JavaCore.TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC, "50"); //$NON-NLS-1$
95
36
96
		// Store default values to default preferences
37
		// Store default values to default preferences
97
	 	IEclipsePreferences defaultPreferences = ((IScopeContext) new DefaultScope()).getNode(JavaCore.PLUGIN_ID);
38
	 	IEclipsePreferences defaultPreferences = ((IScopeContext) new DefaultScope()).getNode(JavaCore.PLUGIN_ID);
(-)model/org/eclipse/jdt/internal/core/util/Util.java (-6 / +119 lines)
Lines 10-29 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core.util;
11
package org.eclipse.jdt.internal.core.util;
12
12
13
import java.io.*;
13
import java.io.File;
14
import java.io.IOException;
15
import java.io.InputStream;
16
import java.io.PrintStream;
14
import java.net.URI;
17
import java.net.URI;
15
import java.util.*;
18
import java.util.Enumeration;
19
import java.util.HashSet;
20
import java.util.Iterator;
21
import java.util.Map;
22
import java.util.Set;
23
import java.util.StringTokenizer;
16
import java.util.zip.ZipEntry;
24
import java.util.zip.ZipEntry;
17
import java.util.zip.ZipFile;
25
import java.util.zip.ZipFile;
18
26
19
import org.eclipse.core.filesystem.EFS;
27
import org.eclipse.core.filesystem.EFS;
20
import org.eclipse.core.filesystem.IFileStore;
28
import org.eclipse.core.filesystem.IFileStore;
21
import org.eclipse.core.resources.*;
29
import org.eclipse.core.resources.IContainer;
22
import org.eclipse.core.runtime.*;
30
import org.eclipse.core.resources.IFile;
31
import org.eclipse.core.resources.IFolder;
32
import org.eclipse.core.resources.IResource;
33
import org.eclipse.core.resources.IWorkspaceRoot;
34
import org.eclipse.core.resources.ProjectScope;
35
import org.eclipse.core.resources.ResourceAttributes;
36
import org.eclipse.core.resources.ResourcesPlugin;
37
import org.eclipse.core.runtime.Assert;
38
import org.eclipse.core.runtime.CoreException;
39
import org.eclipse.core.runtime.IPath;
40
import org.eclipse.core.runtime.IProgressMonitor;
41
import org.eclipse.core.runtime.IStatus;
42
import org.eclipse.core.runtime.Path;
43
import org.eclipse.core.runtime.Platform;
44
import org.eclipse.core.runtime.QualifiedName;
45
import org.eclipse.core.runtime.Status;
23
import org.eclipse.core.runtime.content.IContentType;
46
import org.eclipse.core.runtime.content.IContentType;
24
import org.eclipse.core.runtime.preferences.IScopeContext;
47
import org.eclipse.core.runtime.preferences.IScopeContext;
25
import org.eclipse.core.runtime.preferences.InstanceScope;
48
import org.eclipse.core.runtime.preferences.InstanceScope;
26
import org.eclipse.jdt.core.*;
49
import org.eclipse.jdt.core.IAnnotation;
50
import org.eclipse.jdt.core.IClassFile;
51
import org.eclipse.jdt.core.ICompilationUnit;
52
import org.eclipse.jdt.core.IInitializer;
53
import org.eclipse.jdt.core.IJavaElement;
54
import org.eclipse.jdt.core.IJavaModelStatusConstants;
55
import org.eclipse.jdt.core.IJavaProject;
56
import org.eclipse.jdt.core.IMemberValuePair;
57
import org.eclipse.jdt.core.IMethod;
58
import org.eclipse.jdt.core.IPackageFragment;
59
import org.eclipse.jdt.core.ISourceRange;
60
import org.eclipse.jdt.core.IType;
61
import org.eclipse.jdt.core.JavaConventions;
62
import org.eclipse.jdt.core.JavaCore;
63
import org.eclipse.jdt.core.JavaModelException;
64
import org.eclipse.jdt.core.Signature;
65
import org.eclipse.jdt.core.WorkingCopyOwner;
27
import org.eclipse.jdt.core.compiler.CharOperation;
66
import org.eclipse.jdt.core.compiler.CharOperation;
28
import org.eclipse.jdt.core.dom.ASTNode;
67
import org.eclipse.jdt.core.dom.ASTNode;
29
import org.eclipse.jdt.core.dom.ArrayType;
68
import org.eclipse.jdt.core.dom.ArrayType;
Lines 33-38 Link Here
33
import org.eclipse.jdt.core.dom.SimpleType;
72
import org.eclipse.jdt.core.dom.SimpleType;
34
import org.eclipse.jdt.core.dom.Type;
73
import org.eclipse.jdt.core.dom.Type;
35
import org.eclipse.jdt.core.dom.WildcardType;
74
import org.eclipse.jdt.core.dom.WildcardType;
75
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
36
import org.eclipse.jdt.core.util.IClassFileAttribute;
76
import org.eclipse.jdt.core.util.IClassFileAttribute;
37
import org.eclipse.jdt.core.util.IClassFileReader;
77
import org.eclipse.jdt.core.util.IClassFileReader;
38
import org.eclipse.jdt.core.util.ICodeAttribute;
78
import org.eclipse.jdt.core.util.ICodeAttribute;
Lines 49-54 Link Here
49
import org.eclipse.jdt.internal.compiler.env.EnumConstantSignature;
89
import org.eclipse.jdt.internal.compiler.env.EnumConstantSignature;
50
import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
90
import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
51
import org.eclipse.jdt.internal.compiler.env.IDependent;
91
import org.eclipse.jdt.internal.compiler.env.IDependent;
92
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
52
import org.eclipse.jdt.internal.compiler.impl.Constant;
93
import org.eclipse.jdt.internal.compiler.impl.Constant;
53
import org.eclipse.jdt.internal.compiler.lookup.Binding;
94
import org.eclipse.jdt.internal.compiler.lookup.Binding;
54
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
95
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
Lines 925-930 Link Here
925
	}
966
	}
926
967
927
	/**
968
	/**
969
	 * Initialize the original default java core options.
970
	 * 
971
	 * @return the original default option map
972
	 */
973
	public static Map getOriginalDefaultOptions(Set optionNames) {
974
		// Compiler settings
975
		Map defaultOptionsMap = new CompilerOptions().getMap(); // compiler defaults
976
977
		// Override some compiler defaults
978
		defaultOptionsMap.put(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR, JavaCore.GENERATE);
979
		defaultOptionsMap.put(JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL, JavaCore.PRESERVE);
980
		defaultOptionsMap.put(JavaCore.COMPILER_TASK_TAGS, JavaCore.DEFAULT_TASK_TAGS);
981
		defaultOptionsMap.put(JavaCore.COMPILER_TASK_PRIORITIES, JavaCore.DEFAULT_TASK_PRIORITIES);
982
		defaultOptionsMap.put(JavaCore.COMPILER_TASK_CASE_SENSITIVE, JavaCore.ENABLED);
983
		defaultOptionsMap.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED);
984
		defaultOptionsMap.put(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaCore.ERROR);
985
986
		// Builder settings
987
		defaultOptionsMap.put(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, ""); //$NON-NLS-1$
988
		defaultOptionsMap.put(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, JavaCore.ABORT);
989
		defaultOptionsMap.put(JavaCore.CORE_JAVA_BUILD_DUPLICATE_RESOURCE, JavaCore.WARNING);
990
		defaultOptionsMap.put(JavaCore.CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, JavaCore.CLEAN);
991
		defaultOptionsMap.put(JavaCore.CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER, JavaCore.IGNORE);
992
993
		// JavaCore settings
994
		defaultOptionsMap.put(JavaCore.CORE_JAVA_BUILD_ORDER, JavaCore.IGNORE);
995
		defaultOptionsMap.put(JavaCore.CORE_INCOMPLETE_CLASSPATH, JavaCore.ERROR);
996
		defaultOptionsMap.put(JavaCore.CORE_CIRCULAR_CLASSPATH, JavaCore.ERROR);
997
		defaultOptionsMap.put(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, JavaCore.IGNORE);
998
		defaultOptionsMap.put(JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS, JavaCore.ENABLED);
999
		defaultOptionsMap.put(JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS, JavaCore.ENABLED);
1000
1001
		// encoding setting comes from resource plug-in
1002
		boolean hasOptionNames = optionNames != null;
1003
		if (hasOptionNames) {
1004
			optionNames.add(JavaCore.CORE_ENCODING);
1005
		}
1006
1007
		// Formatter settings
1008
		Map codeFormatterOptionsMap = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); // code formatter defaults
1009
		for (Iterator iter = codeFormatterOptionsMap.entrySet().iterator(); iter.hasNext();) {
1010
			Map.Entry entry = (Map.Entry) iter.next();
1011
			String optionName = (String) entry.getKey();
1012
			defaultOptionsMap.put(optionName, entry.getValue());
1013
			if (hasOptionNames) {
1014
				optionNames.add(optionName);
1015
			}
1016
		}
1017
1018
		// CodeAssist settings
1019
		defaultOptionsMap.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.DISABLED);
1020
		defaultOptionsMap.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.DISABLED);
1021
		defaultOptionsMap.put(JavaCore.CODEASSIST_IMPLICIT_QUALIFICATION, JavaCore.DISABLED);
1022
		defaultOptionsMap.put(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$
1023
		defaultOptionsMap.put(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$
1024
		defaultOptionsMap.put(JavaCore.CODEASSIST_STATIC_FINAL_FIELD_PREFIXES, ""); //$NON-NLS-1$
1025
		defaultOptionsMap.put(JavaCore.CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$
1026
		defaultOptionsMap.put(JavaCore.CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$
1027
		defaultOptionsMap.put(JavaCore.CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$
1028
		defaultOptionsMap.put(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$
1029
		defaultOptionsMap.put(JavaCore.CODEASSIST_STATIC_FINAL_FIELD_SUFFIXES, ""); //$NON-NLS-1$
1030
		defaultOptionsMap.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$
1031
		defaultOptionsMap.put(JavaCore.CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$
1032
		defaultOptionsMap.put(JavaCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaCore.ENABLED);
1033
		defaultOptionsMap.put(JavaCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaCore.DISABLED);
1034
		defaultOptionsMap.put(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
1035
		defaultOptionsMap.put(JavaCore.CODEASSIST_SUGGEST_STATIC_IMPORTS, JavaCore.ENABLED);
1036
1037
		// Time out for parameter names
1038
		defaultOptionsMap.put(JavaCore.TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC, "50"); //$NON-NLS-1$
1039
		return defaultOptionsMap;
1040
	}
1041
	/**
928
	 * Returns the line separator found in the given text.
1042
	 * Returns the line separator found in the given text.
929
	 * If it is null, or not found return the line delimiter for the given project.
1043
	 * If it is null, or not found return the line delimiter for the given project.
930
	 * If the project is null, returns the line separator for the workspace.
1044
	 * If the project is null, returns the line separator for the workspace.
Lines 1583-1589 Link Here
1583
	protected static boolean isAttributeSupported(int attribute) {
1697
	protected static boolean isAttributeSupported(int attribute) {
1584
		return (EFS.getLocalFileSystem().attributes() & attribute) != 0;
1698
		return (EFS.getLocalFileSystem().attributes() & attribute) != 0;
1585
	}
1699
	}
1586
1587
	/**
1700
	/**
1588
	 * Returns whether the given resource is read-only or not.
1701
	 * Returns whether the given resource is read-only or not.
1589
	 * @param resource
1702
	 * @param resource

Return to bug 263564