Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java')
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java210
1 files changed, 137 insertions, 73 deletions
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java
index 7ad19d2235..0db3ddb172 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java
@@ -9,7 +9,6 @@ import org.eclipse.core.runtime.*;
import org.eclipse.core.resources.*;
import java.io.*;
-import java.net.URL;
import java.util.*;
import org.eclipse.jdt.internal.compiler.*;
@@ -45,19 +44,19 @@ public final class JavaCore extends Plugin implements IExecutableExtension {
* The plug-in identifier of the Java core support
* (value <code>"org.eclipse.jdt.core"</code>).
*/
- public static final String PLUGIN_ID = "org.eclipse.jdt.core"/*nonNLS*/; // getPlugin().getDescriptor().getUniqueIdentifier();
+ public static final String PLUGIN_ID = "org.eclipse.jdt.core"; // getPlugin().getDescriptor().getUniqueIdentifier();
/**
* The identifier for the Java builder
* (value <code>"org.eclipse.jdt.core.javabuilder"</code>).
*/
- public static final String BUILDER_ID = PLUGIN_ID + ".javabuilder"/*nonNLS*/;
+ public static final String BUILDER_ID = PLUGIN_ID + ".javabuilder";
/**
* The identifier for the Java model
* (value <code>"org.eclipse.jdt.core.javamodel"</code>).
*/
- public static final String MODEL_ID = PLUGIN_ID + ".javamodel"/*nonNLS*/;
+ public static final String MODEL_ID = PLUGIN_ID + ".javamodel";
/**
* The identifier for the Java nature
@@ -67,82 +66,76 @@ public final class JavaCore extends Plugin implements IExecutableExtension {
*
* @see org.eclipse.core.resources.IProject#hasNature
*/
- public static final String NATURE_ID = PLUGIN_ID + ".javanature"/*nonNLS*/;
+ public static final String NATURE_ID = PLUGIN_ID + ".javanature";
/**
* Name of the handle id attribute in a Java marker
*/
- private static final String ATT_HANDLE_ID= "org.eclipse.jdt.internal.core.JavaModelManager.handleId"/*nonNLS*/;
+ private static final String ATT_HANDLE_ID= "org.eclipse.jdt.internal.core.JavaModelManager.handleId";
/**
* Names of recognized configurable options
*/
- public static final String COMPILER_LOCAL_VARIABLE_ATTR = PLUGIN_ID + ".compiler.debug.localVariable"/*nonNLS*/;
+ public static final String COMPILER_LOCAL_VARIABLE_ATTR = PLUGIN_ID + ".compiler.debug.localVariable";
// possible values are GENERATE or DO_NOT_GENERATE (default is DO_NOT_GENERATE)
- public static final String COMPILER_LINE_NUMBER_ATTR = PLUGIN_ID + ".compiler.debug.lineNumber"/*nonNLS*/;
+ public static final String COMPILER_LINE_NUMBER_ATTR = PLUGIN_ID + ".compiler.debug.lineNumber";
// possible values are GENERATE or DO_NOT_GENERATE (default is GENERATE)
- public static final String COMPILER_SOURCE_FILE_ATTR = PLUGIN_ID + ".compiler.debug.sourceFile"/*nonNLS*/;
+ public static final String COMPILER_SOURCE_FILE_ATTR = PLUGIN_ID + ".compiler.debug.sourceFile";
// possible values are GENERATE or DO_NOT_GENERATE (default is GENERATE)
- public static final String COMPILER_CODEGEN_UNUSED_LOCAL = PLUGIN_ID + ".compiler.codegen.unusedLocal"/*nonNLS*/;
+ public static final String COMPILER_CODEGEN_UNUSED_LOCAL = PLUGIN_ID + ".compiler.codegen.unusedLocal";
// possible values are PRESERVE or OPTIMIZE_OUT (default is OPTIMIZE_OUT)
- public static final String COMPILER_CODEGEN_TARGET_PLATFORM = PLUGIN_ID + ".compiler.codegen.targetPlatform"/*nonNLS*/;
+ public static final String COMPILER_CODEGEN_TARGET_PLATFORM = PLUGIN_ID + ".compiler.codegen.targetPlatform";
// possible values are VERSION_1_1 or VERSION_1_2 (default is VERSION_1_1)
- public static final String COMPILER_PB_UNREACHABLE_CODE = PLUGIN_ID + ".compiler.problem.unreachableCode"/*nonNLS*/;
+ public static final String COMPILER_PB_UNREACHABLE_CODE = PLUGIN_ID + ".compiler.problem.unreachableCode";
// possible values are ERROR or WARNING (default is ERROR)
- public static final String COMPILER_PB_INVALID_IMPORT = PLUGIN_ID + ".compiler.problem.invalidImport"/*nonNLS*/;
+ public static final String COMPILER_PB_INVALID_IMPORT = PLUGIN_ID + ".compiler.problem.invalidImport";
// possible values are ERROR or WARNING (default is ERROR)
- public static final String COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD = PLUGIN_ID + ".compiler.problem.overridingPackageDefaultMethod"/*nonNLS*/;
+ public static final String COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD = PLUGIN_ID + ".compiler.problem.overridingPackageDefaultMethod";
// possible values are WARNING or IGNORE (default is WARNING)
- public static final String COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME = PLUGIN_ID + ".compiler.problem.methodWithConstructorName"/*nonNLS*/;
+ public static final String COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME = PLUGIN_ID + ".compiler.problem.methodWithConstructorName";
// possible values are WARNING or IGNORE (default is WARNING)
- public static final String COMPILER_PB_DEPRECATION = PLUGIN_ID + ".compiler.problem.deprecation"/*nonNLS*/;
+ public static final String COMPILER_PB_DEPRECATION = PLUGIN_ID + ".compiler.problem.deprecation";
// possible values are WARNING or IGNORE (default is WARNING)
- public static final String COMPILER_PB_HIDDEN_CATCH_BLOCK = PLUGIN_ID + ".compiler.problem.hiddenCatchBlock"/*nonNLS*/;
+ public static final String COMPILER_PB_HIDDEN_CATCH_BLOCK = PLUGIN_ID + ".compiler.problem.hiddenCatchBlock";
// possible values are WARNING or IGNORE (default is WARNING)
- public static final String COMPILER_PB_UNUSED_LOCAL = PLUGIN_ID + ".compiler.problem.unusedLocal"/*nonNLS*/;
+ public static final String COMPILER_PB_UNUSED_LOCAL = PLUGIN_ID + ".compiler.problem.unusedLocal";
// possible values are WARNING or IGNORE (default is WARNING)
- public static final String COMPILER_PB_UNUSED_PARAMETER = PLUGIN_ID + ".compiler.problem.unusedParameter"/*nonNLS*/;
+ public static final String COMPILER_PB_UNUSED_PARAMETER = PLUGIN_ID + ".compiler.problem.unusedParameter";
// possible values are WARNING or IGNORE (default is WARNING)
- public static final String COMPILER_PB_SYNTHETIC_ACCESS_EMULATION = PLUGIN_ID + ".compiler.problem.syntheticAccessEmulation"/*nonNLS*/;
- // possible values are WARNING or IGNORE (default is IGNORE)
-
- public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID + ".computeJavaBuildOrder"/*nonNLS*/;
+ public static final String COMPILER_PB_SYNTHETIC_ACCESS_EMULATION = PLUGIN_ID + ".compiler.problem.syntheticAccessEmulation";
+ // possible values are WARNING or IGNORE (default is IGNORE)
+
+ public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID + ".computeJavaBuildOrder";
// possible values are COMPUTE or IGNORE (default is COMPUTE)
/**
* Possible values for configurable options
*/
- public static final String GENERATE = "generate"/*nonNLS*/;
- public static final String DO_NOT_GENERATE = "do not generate"/*nonNLS*/;
- public static final String PRESERVE = "preserve"/*nonNLS*/;
- public static final String OPTIMIZE_OUT = "optimize out"/*nonNLS*/;
- public static final String VERSION_1_1 = "1.1"/*nonNLS*/;
- public static final String VERSION_1_2 = "1.2"/*nonNLS*/;
- public static final String ERROR = "error"/*nonNLS*/;
- public static final String WARNING = "warning"/*nonNLS*/;
- public static final String IGNORE = "ignore"/*nonNLS*/;
- public static final String COMPUTE = "compute"/*nonNLS*/;
+ public static final String GENERATE = "generate";
+ public static final String DO_NOT_GENERATE = "do not generate";
+ public static final String PRESERVE = "preserve";
+ public static final String OPTIMIZE_OUT = "optimize out";
+ public static final String VERSION_1_1 = "1.1";
+ public static final String VERSION_1_2 = "1.2";
+ public static final String ERROR = "error";
+ public static final String WARNING = "warning";
+ public static final String IGNORE = "ignore";
+ public static final String COMPUTE = "compute";
private static Hashtable ConfigurableOptions;
private static Hashtable Variables = new Hashtable(5);
- // possible values are WARNING or IGNORE (default is IGNORE)
-
- public static final String COMPILER_PB_NON_EXTERNALIZED_STRING_LITERAL = PLUGIN_ID + ".compiler.problem.nonExternalizedStringLiteral"/*nonNLS*/;
-
- private static Hashtable DefaultOptions;
- private final static String PropertiesBundleName = "org.eclipse.jdt.core.JavaCore"/*nonNLS*/;
/**
* Creates the Java core plug-in.
*/
@@ -223,11 +216,11 @@ public static IJavaElement create(IFile file) {
String extension= file.getProjectRelativePath().getFileExtension();
if (extension != null) {
extension= extension.toLowerCase();
- if (extension.equals("java"/*nonNLS*/)) {
+ if (extension.equals("java")) {
return createCompilationUnitFrom(file);
- } else if (extension.equals("class"/*nonNLS*/)) {
+ } else if (extension.equals("class")) {
return createClassFileFrom(file);
- } else if (extension.equals("jar"/*nonNLS*/) || extension.equals("zip"/*nonNLS*/)) {
+ } else if (extension.equals("jar") || extension.equals("zip")) {
return createJarPackageFragmentRootFrom(file);
}
}
@@ -419,7 +412,7 @@ private static IJavaElement determineIfOnClasspath(IResource resource, IJavaProj
}
pkgName.append(segment);
if (j < pkgPath.segmentCount() - 1) {
- pkgName.append("."/*nonNLS*/);
+ pkgName.append(".");
}
}
return root.getPackageFragment(pkgName.toString());
@@ -468,33 +461,105 @@ public static String[] getClasspathVariableNames() {
/**
* Answers a set of configurable options with their default values.
* These options allow to configure the behavior of the underlying components.
+ *
+ * Recognized options are listed below, optionName = possibleValue1 / possibleValue2
+ * where [] are enclosing the default value of the corresponding option.
+ *
+ * Note: more options might be added in further releases.
+ *
+ * RECOGNIZED OPTIONS:
+ *
+ * COMPILER_LOCAL_VARIABLE_ATTR = [GENERATE] | DO_NOT_GENERATE
+ * When generated, this attribute will enable local variable names to be displayed
+ * in debugger, only in place where variables are definitely assigned
+ * (.class file is then bigger)
+ *
+ * COMPILER_LINE_NUMBER_ATTR = [GENERATE] | DO_NOT_GENERATE
+ * When generated, this attribute will enable source code highlighting in debugger
+ * (.class file is then bigger).
+ *
+ * COMPILER_SOURCE_FILE_ATTR = [GENERATE] | DO_NOT_GENERATE
+ * When generated, this attribute will enable the debugger to present the
+ * corresponding source code.
+ *
+ * COMPILER_CODEGEN_UNUSED_LOCAL = [PRESERVE] | OPTIMIZE_OUT
+ * Unless requested to preserve unused local variables (i.e. never read), the
+ * compiler will optimize them out, potentially altering debugging
+ *
+ * COMPILER_CODEGEN_TARGET_PLATFORM = [VERSION_1_1] | VERSION_1_2
+ * Generate .class files either backward compatible with JVM 1.1 or only executable
+ * on JVM 1.2 and later
+ *
+ * COMPILER_PB_UNREACHABLE_CODE = [ERROR] | WARNING
+ * Unreachable code can either be reported as an error or a warning
+ *
+ * COMPILER_PB_INVALID_IMPORT = [ERROR] | WARNING
+ * An import statement that cannot be resolved might either be reported
+ * either as an error or as a warning
+ *
+ * COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD = [WARNING] | IGNORE
+ * A package default method is not visible in a different package, and thus
+ * cannot be overriden. When enabling this option, the compiler will signal
+ * such scenarii.
+ *
+ * COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME = [WARNING] | IGNORE
+ * Naming a method with a constructor name is generally considered poor
+ * style programming. When enabling this option, the compiler will signal such
+ * scenarii
+ *
+ * COMPILER_PB_DEPRECATION = [WARNING] | IGNORE
+ * When enabled, the compiler will signal use of deprecated API.
+ *
+ * COMPILER_PB_HIDDEN_CATCH_BLOCK = [WARNING] | IGNORE
+ * Locally to a try statement, some catch blocks may hide others
+ * (e.g. try { throw new java.io.CharConversionException();
+ * } catch (java.io.CharConversionException e) {
+ * } catch (java.io.IOException e) {}).
+ * When enabling this option, the compiler will issue a warning for hidden catch
+ * blocks corresponding to checked exceptions
+ *
+ * COMPILER_PB_UNUSED_LOCAL = WARNING | [IGNORE]
+ * When enabled, the compiler will issue a warning for unused local variables
+ * (i.e. variables never read from)
+ *
+ * COMPILER_PB_UNUSED_PARAMETER = WARNING | [IGNORE]
+ * When enabled, the compiler will issue a warning for unused method parameters
+ * (i.e. parameters never read from)
+ *
+ * COMPILER_PB_SYNTHETIC_ACCESS_EMULATION = WARNING | [IGNORE]
+ * When enabled, the compiler will issue a warning whenever it emulates access
+ * to a non-accessible member of an enclosing type
+ *
+ * CORE_JAVA_BUILD_ORDER = [COMPUTE] | IGNORE
+ * When enabled, the build order is automatically reflecting the classpath on each
+ * classpath change action. It can still be modified manually afterwards.
*/
+
public static Hashtable getDefaultOptions(){
- if (DefaultOptions == null) {
- DefaultOptions = new Hashtable(10);
-
- try{
- ResourceBundle bundle =
- ResourceBundle.getBundle(PropertiesBundleName,Locale.getDefault());
-
- Enumeration enum = bundle.getKeys();
- while(enum.hasMoreElements()){
- String id = (String)enum.nextElement();
- System.out.println(id);
- DefaultOptions.put(id,bundle.getString(id));
- }
- } catch(Exception ex){}
- }
- return (Hashtable)DefaultOptions.clone();
-
-
-}
+ Hashtable defaultOptions = new Hashtable(10);
-private static IPath getInstallLocation() {
- return new Path(getPlugin().getDescriptor().getInstallURL().getFile());
-}
+ // Compiler settings
+ defaultOptions.put(COMPILER_LOCAL_VARIABLE_ATTR, GENERATE);
+ defaultOptions.put(COMPILER_LINE_NUMBER_ATTR, GENERATE);
+ defaultOptions.put(COMPILER_SOURCE_FILE_ATTR, GENERATE);
+ defaultOptions.put(COMPILER_CODEGEN_UNUSED_LOCAL, PRESERVE);
+ defaultOptions.put(COMPILER_CODEGEN_TARGET_PLATFORM, VERSION_1_1);
+ defaultOptions.put(COMPILER_PB_UNREACHABLE_CODE, ERROR);
+ defaultOptions.put(COMPILER_PB_INVALID_IMPORT, ERROR);
+ defaultOptions.put(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD, WARNING);
+ defaultOptions.put(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME, WARNING);
+ defaultOptions.put(COMPILER_PB_DEPRECATION, WARNING);
+ defaultOptions.put(COMPILER_PB_HIDDEN_CATCH_BLOCK, WARNING);
+ defaultOptions.put(COMPILER_PB_UNUSED_LOCAL, IGNORE);
+ defaultOptions.put(COMPILER_PB_UNUSED_PARAMETER, IGNORE);
+ defaultOptions.put(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, IGNORE);
+
+ // JavaCore settings
+ defaultOptions.put(CORE_JAVA_BUILD_ORDER, IGNORE);
+ return defaultOptions;
+}
/**
* Returns the single instance of the Java core plug-in runtime class.
* Equivalent to <code>(JavaCore) getPlugin()</code>.
@@ -575,7 +640,7 @@ public static IClasspathEntry getResolvedClasspathEntry(IClasspathEntry entry) {
return JavaCore.newProjectEntry(resolvedPath); // internal project
case IResource.FILE :
String extension = resolvedResource.getFileExtension();
- if ("jar"/*nonNLS*/.equalsIgnoreCase(extension) || "zip"/*nonNLS*/.equalsIgnoreCase(extension)){ // internal binary archive
+ if ("jar".equalsIgnoreCase(extension) || "zip".equalsIgnoreCase(extension)){ // internal binary archive
return JavaCore.newLibraryEntry(
resolvedPath,
getResolvedVariablePath(entry.getSourceAttachmentPath()),
@@ -595,7 +660,7 @@ public static IClasspathEntry getResolvedClasspathEntry(IClasspathEntry entry) {
File externalFile = (File) target;
if (externalFile.isFile()){
String fileName = externalFile.getName().toLowerCase();
- if (fileName.endsWith(".jar"/*nonNLS*/) || fileName.endsWith(".zip"/*nonNLS*/)){ // external binary archive
+ if (fileName.endsWith(".jar") || fileName.endsWith(".zip")){ // external binary archive
return JavaCore.newLibraryEntry(
resolvedPath,
getResolvedVariablePath(entry.getSourceAttachmentPath()),
@@ -686,7 +751,7 @@ public static boolean isReferencedBy(IJavaElement element, IMarkerDelta markerDe
*/
public static IClasspathEntry newLibraryEntry(IPath path, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath) {
- Assert.isTrue(path.isAbsolute(), Util.bind("classpath.needAbsolutePath"/*nonNLS*/));
+ Assert.isTrue(path.isAbsolute(), "path for IClasspathEntry must be absolute");
return new ClasspathEntry(
IPackageFragmentRoot.K_BINARY,
IClasspathEntry.CPE_LIBRARY,
@@ -708,7 +773,7 @@ public static IClasspathEntry newLibraryEntry(IPath path, IPath sourceAttachment
* The prerequisite project is referred to using an absolute path relative to the workspace root.
*/
public static IClasspathEntry newProjectEntry(IPath path){
- Assert.isTrue(path.isAbsolute(), Util.bind("classpath.needAbsolutePath"/*nonNLS*/));
+ Assert.isTrue(path.isAbsolute(), "path for IClasspathEntry must be absolute");
return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE, IClasspathEntry.CPE_PROJECT, path, null, null);
}
/**
@@ -728,7 +793,7 @@ public static IRegion newRegion() {
* context of the containing project (a source entry "Proj1/src" cannot be used on the classpath of Proj2).
*/
public static IClasspathEntry newSourceEntry(IPath path){
- Assert.isTrue(path.isAbsolute(), Util.bind("classpath.needAbsolutePath"/*nonNLS*/));
+ Assert.isTrue(path.isAbsolute(), "path for IClasspathEntry must be absolute");
return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE, IClasspathEntry.CPE_SOURCE, path, null, null);
}
/**
@@ -761,7 +826,7 @@ public static IClasspathEntry newSourceEntry(IPath path){
* or <code>null</code> if <code>archivePath</code> is also <code>null</code>
*/
public static IClasspathEntry newVariableEntry(IPath variablePath, IPath variableSourceAttachmentPath, IPath sourceAttachmentRootPath){
- Assert.isTrue(variablePath != null && variablePath.segmentCount() >= 1, Util.bind("classpath.illegalVariablePath"/*nonNLS*/));
+ Assert.isTrue(variablePath != null && variablePath.segmentCount() >= 1, "invalid variable path");
return new ClasspathEntry(
IPackageFragmentRoot.K_SOURCE,
IClasspathEntry.CPE_VARIABLE,
@@ -855,7 +920,7 @@ public static void setClasspathVariable(String variableName, IPath path) throws
*/
public static void setClasspathVariable(String variableName, IPath path, IProgressMonitor monitor) throws JavaModelException {
- Assert.isTrue(path != null, Util.bind("classpath.nullVariablePath"/*nonNLS*/));
+ Assert.isTrue(path != null, "variable path cannot be null");
updateVariableValue(variableName, path, monitor);
}
/* (non-Javadoc)
@@ -1004,5 +1069,4 @@ private static void updateVariableValue(String variableName, IPath path, IProgre
}
}
}
-
}

Back to the top